Loading...
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
Test Cases
# CPU Memory Points
1 1 ms 3236 kb 1 Accepted
2 1 ms 3384 kb 1 Accepted
3 1 ms 3320 kb 0 Wrong Answer
4 0 ms 0 kb 0 Skipped
5 0 ms 0 kb 0 Skipped
6 0 ms 0 kb 0 Skipped
7 0 ms 0 kb 0 Skipped
8 0 ms 0 kb 0 Skipped
9 0 ms 0 kb 0 Skipped
10 0 ms 0 kb 0 Skipped
11 0 ms 0 kb 0 Skipped
Source Code
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4.  
  5. using namespace std;
  6.  
  7. // Function to select the maximum number of warriors
  8. int maxWarriors(vector<pair<int, int>>& warriors, int N) {
  9. set<int> selectedNumbers; // Set to keep track of selected identification numbers
  10.  
  11. for (int i = 0; i < N; ++i) {
  12. // Add both identification numbers to the set
  13. selectedNumbers.insert(warriors[i].first);
  14. selectedNumbers.insert(warriors[i].second);
  15. }
  16.  
  17. return selectedNumbers.size();
  18. }
  19.  
  20. int main() {
  21. int N;
  22. cin >> N;
  23. vector<pair<int, int>> warriors(N);
  24.  
  25. for (int i = 0; i < N; ++i) {
  26. cin >> warriors[i].first >> warriors[i].second;
  27. }
  28.  
  29. int result = maxWarriors(warriors, N);
  30. cout << result << endl;
  31.  
  32. return 0;
  33. }
  34.