/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 544.0 KiB
#3 Accepted 1ms 540.0 KiB
#4 Accepted 1ms 540.0 KiB
#5 Accepted 1ms 540.0 KiB
#6 Accepted 1ms 332.0 KiB
#7 Accepted 1ms 548.0 KiB
#8 Accepted 1ms 540.0 KiB
#9 Wrong Answer 1ms 540.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>;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    o_set<int> l, r;
    for (auto &x : v)
    {
        cin >> x;
        r.insert(x);
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int x = v[i];
        r.erase(x);
        int chuto = l.order_of_key(x + 1);
        if (chuto >= x)
        {
            ans++;
            l.insert(x);
            continue;
        }
        int boro = r.size() - r.order_of_key(x);
        if (boro >= x)
        {
            ans++;
        }
        l.insert(x);
    }
    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:08:04
Judged At
2025-04-06 16:08:04
Judged By
Score
7
Total Time
1ms
Peak Memory
548.0 KiB