fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. long long n, *x;
  7. cin >> n;
  8. x = new long long[n];
  9. for (int i = 0; i < n; i++)
  10. cin >> x[i];
  11. sort(x, x + n);
  12. long long k, y;
  13. k = 1;
  14. y = x[0];
  15. for (int i = 1; i < n; i++) {
  16. if (x[i] == y)
  17. k++;
  18. else {
  19. if (k % 2 != 0) {
  20. cout << y;
  21. return 0;
  22. }
  23. else {
  24. k = 1;
  25. y = x[i];
  26. }
  27. }
  28. }
  29. cout << x[n - 1];
  30. delete []x;
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 15240KB
stdin
11
10 100 1000 100 100 100 1000 10 100 1000 100
stdout
1000