2 solutions

  • 0
    @ 2026-10-27 8:35:25
    #include <bits/stdc++.h>
    using namespace std;
    #define FIO(s)                    \
        freopen(s ".in", "r", stdin); \
        freopen(s ".out", "w", stdout);
    template <typename T>
    void chkmx(T &x, T y) { x = max(x, y); }
    int n;
    map<int, int> mp;
    int mx;
    int main()
    {
        FIO("delete");
        ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        cin >> n >> n;
        for (int i = 1; i <= n; i++)
        {
            int x;
            cin >> x;
            chkmx(mx, ++mp[x]);
            if (mx > i - mx)
                cout << mx - (i - mx) << ' ';
            else
                cout << (i & 1) << ' ';
        }
        cout << '\n';
        return 0;
    }
    

    Information

    ID
    3152
    Time
    1000ms
    Memory
    1024MiB
    Difficulty
    10
    Tags
    (None)
    # Submissions
    6
    Accepted
    1
    Uploaded By