5 solutions

  • -1
    @ 2025-7-13 16:03:19

    #include <bits/stdc++.h> using namespace std;

    int main() { int n, a[100005], x, maxi; scanf("%d", &n); for (int i = 0; i <= n; i++) { scanf("%d", &x); a[x] ++; }

    maxi = 0;
    
    for (int j = 0; j <= 10005; j++) {
    	if (a[j] > a[maxi]) {
    		maxi = j;
    	}
    
    	else if (a[j] == a[maxi] && j < maxi) {
    		maxi = j;
    	}
    }
    printf("%d", maxi);
    return 0;
    

    }

    Information

    ID
    391
    Time
    1000ms
    Memory
    64MiB
    Difficulty
    7
    Tags
    # Submissions
    62
    Accepted
    14
    Uploaded By