5 solutions

  • -1
    @ 2025-7-13 15:54:12

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

    int main() { int n, a[100005], x, maxi; cin >> n; for (int i = 1; i <= n; i++) { cin >> x; a[x]++; } maxi = 0; for (int j = 0; j <= 100005; j++) { if (a[j] > a[maxi]) { maxi = j; } else if (a[j] == a[maxi] && j < maxi) { maxi = j; } } printf("%d\n", maxi);

    return 0;
    

    }

    Information

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