/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 540.0 KiB
#3 Accepted 1ms 540.0 KiB
#4 Accepted 1ms 540.0 KiB
#5 Accepted 1ms 540.0 KiB
#6 Accepted 1ms 772.0 KiB
#7 Accepted 1ms 512.0 KiB
#8 Accepted 1ms 556.0 KiB
#9 Accepted 1ms 540.0 KiB
#10 Accepted 1ms 516.0 KiB
#11 Wrong Answer 1ms 488.0 KiB

Code

#ifndef LOCAL
#include <bits/stdc++.h>
#define debug(...)
#endif

#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;
#define int long long
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using ordered_set2 = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;

void shelby() {
    int n;
    cin >> n;
    vector<int> v(n);
    cinv(v)
    vector<int> ans(n);
    ordered_set<int> o;
    for (int i = 0; i < n; ++i) {
        int x = o.order_of_key(v[i] + 1);
        if (x >= v[i]) ans[i] = 1;
        o.insert(v[i]);
    }
    debug(ans);
    ordered_set2<int> o2;
    for (int i = n - 1; ~i; --i) {
        int x = o2.size() - o2.order_of_key(v[i]);
        if (x >= v[i]) ans[i] |= 1;
        o2.insert(v[i]);
    }
    cout << count(ans.begin(), ans.end(), 1) << '\n';
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    // cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case " << _ << ": ";
        shelby();
    }
}

Information

Submit By
Type
Submission
Problem
P1184 The Curious Kid and the Number Game
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-08 20:47:58
Judged At
2025-04-08 20:47:58
Judged By
Score
9
Total Time
1ms
Peak Memory
772.0 KiB