/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 348.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 1ms 484.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 1ms 532.0 KiB
#7 Accepted 1ms 320.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 1ms 532.0 KiB
#10 Wrong Answer 1ms 532.0 KiB
#11 Wrong Answer 1ms 532.0 KiB

Code

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

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


void solve() {
    o_set<pair<int, int>> st;
    int n;
    cin >> n;
    vector<int> v(n);
    vector<bool> mark(n);
    for(auto &x: v) 
        cin >> x;
    for(int i = 0; i < n; i++) {
        int cnt = st.order_of_key({v[i] + 1, 0});
        if(cnt >= v[i]) mark[i] = 1;
        st.insert({v[i], i});
    }
    st.clear();
    for(int i = n - 1; i >= 0; i--) {
        int cnt = (n - i) - st.order_of_key({v[i], 0});
        if(cnt >= v[i]) mark[i] = 1;
        st.insert({v[i], i});
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(mark[i]) ans++;
    }
    cout << ans << '\n';
    return;
}

int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int tc = 1;
    // cin >> tc;
    for(int kase = 1; kase <= tc; kase++) {
        //cout << "Case " << kase << ": ";
        solve();
    }
    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:29:40
Judged At
2025-04-06 16:29:40
Judged By
Score
9
Total Time
1ms
Peak Memory
532.0 KiB