Submission
# | When | Author | Problem | Language | CPU | Memory | |
---|---|---|---|---|---|---|---|
20861 | 2024-06-12 23:59:21 | AHAMMED_99 | Warrior of Exoland | C++ 17 | 1 ms | 3384 kb | Wrong Answer - 3 |
Source Code
#include <iostream> #include <vector> #include <set> using namespace std; // Function to select the maximum number of warriors int maxWarriors(vector<pair<int, int>>& warriors, int N) { set<int> selectedNumbers; // Set to keep track of selected identification numbers for (int i = 0; i < N; ++i) { // Add both identification numbers to the set selectedNumbers.insert(warriors[i].first); selectedNumbers.insert(warriors[i].second); } return selectedNumbers.size(); } int main() { int N; cin >> N; vector<pair<int, int>> warriors(N); for (int i = 0; i < N; ++i) { cin >> warriors[i].first >> warriors[i].second; } int result = maxWarriors(warriors, N); cout << result << endl; return 0; }