fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. signed main(){
  5. ios::sync_with_stdio(false);
  6.  
  7. unsigned long long n; // n <= 1e6
  8. long long m = 1000;
  9. long long o = 1000000;
  10. long long largest_pos[o];
  11. long long largest_nextpos = 1;
  12. cin >> n;
  13. unsigned long long a[m]; // a <= 1000
  14. for (long long i = 1; i <= n; i++){
  15. cin >> m;
  16. a[m]++;
  17. if (a[m] > a[largest_pos[largest_nextpos]]){
  18. largest_pos[1]=m;
  19. largest_nextpos=1;
  20. }
  21. else if (a[m] = a[largest_pos[largest_nextpos]]){
  22. largest_nextpos++;
  23. }
  24. else continue;
  25. }
  26. //for (long long j = 1; j <= n;)
  27. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty