Loading...
Submission
# When Author Problem Language CPU Memory
20862 2024-06-13 00:00:55 AHAMMED_99 Warrior of Exoland C 3 ms 3472 kb Wrong Answer - 3
Test Cases
# CPU Memory Points
1 2 ms 3472 kb 1 Accepted
2 3 ms 3472 kb 1 Accepted
3 3 ms 3404 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 <stdio.h>
  2. #include <stdbool.h>
  3.  
  4. #define MAX_IDENTIFICATION 400001
  5. #define MAX_N 200001
  6.  
  7. // Function to select the maximum number of warriors
  8. int maxWarriors(int warriors[][2], int N) {
  9. bool selectedNumbers[MAX_IDENTIFICATION] = {false}; // Array to keep track of selected identification numbers
  10.  
  11. for (int i = 0; i < N; ++i) {
  12. // Add both identification numbers to the array
  13. selectedNumbers[warriors[i][0]] = true;
  14. selectedNumbers[warriors[i][1]] = true;
  15. }
  16.  
  17. int count = 0;
  18. for (int i = 1; i < MAX_IDENTIFICATION; ++i) {
  19. if (selectedNumbers[i]) {
  20. count++;
  21. }
  22. }
  23.  
  24. return count;
  25. }
  26.  
  27. int main() {
  28. int N;
  29. scanf("%d", &N);
  30. int warriors[MAX_N][2];
  31.  
  32. for (int i = 0; i < N; ++i) {
  33. scanf("%d %d", &warriors[i][0], &warriors[i][1]);
  34. }
  35.  
  36. int result = maxWarriors(warriors, N);
  37. printf("%d\n", result);
  38.  
  39. return 0;
  40. }
  41.