/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 532.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 1ms 516.0 KiB
#5 Accepted 1ms 324.0 KiB
#6 Accepted 1ms 532.0 KiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 1ms 532.0 KiB
#10 Accepted 1ms 432.0 KiB
#11 Accepted 1ms 532.0 KiB
#12 Accepted 1ms 352.0 KiB
#13 Accepted 1ms 444.0 KiB
#14 Accepted 1ms 532.0 KiB
#15 Accepted 1ms 532.0 KiB
#16 Accepted 1ms 532.0 KiB
#17 Accepted 4ms 448.0 KiB
#18 Accepted 4ms 532.0 KiB
#19 Accepted 4ms 532.0 KiB
#20 Wrong Answer 4ms 532.0 KiB

Code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    map<int, int> cl, cr;
    o_set<pair<int, int>> l, r;
    for (auto &x : v)
    {
        cin >> x;
        r.insert({x, INT_MAX});
        cr[x]++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int x = v[i];
        // left a chuto
        int chuto = l.order_of_key({x, 0});
        chuto += cl[x];
        cl[x]++;
        l.insert({x, INT_MAX});
        int f = 0;
        if (chuto >= x)
        {
            ans++;
            f = 1;
            // continue;
        }
        cr[x]--;
        int boro = cr[x];
        boro += (n - i - 1 - cr[x]) - (r.order_of_key({x, 0}));
        if (cr[x] == 0)
            r.erase({x, INT_MAX});
        if (boro >= x and !f)
        {
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1184 The Curious Kid and the Number Game
Contest
Brain Booster #9
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-06 16:06:11
Judged At
2025-04-06 16:06:11
Judged By
Score
18
Total Time
4ms
Peak Memory
532.0 KiB