/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 396.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 548.0 KiB
#4 Wrong Answer 1ms 532.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 1ms 352.0 KiB
#7 Accepted 1ms 444.0 KiB
#8 Accepted 1ms 500.0 KiB
#9 Wrong Answer 1ms 384.0 KiB

Code

/**
 *    author:   Binoy Barman
 *    created:  2025-04-06 21:24:16
**/

#include<bits/stdc++.h>
#ifdef LOCAL
#include "algo/debug.h"
#else
#define dbg(...) 42
#endif
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = 2e9;

// #define int long long
#define nl '\n'
#define all(v) v.begin(), v.end()
#define clg(x) (32 - __builtin_clz(x))
#define Testcase_Handler int tts, tc = 0; cin >> tts; hell: while(tc++ < tts)
#define uniq(v) sort(all(v)), v.resize(distance(v.begin(), unique(v.begin(), v.end())))
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> istream& operator>>(istream& in, vector<T>& a) {for(auto &x : a) in >> x; return in;};
template<typename A, typename B> istream& operator>>(istream& in, pair<A, B>& p) {in >> p.first >> p.second; return in;};
template<typename T> ostream& operator<<(ostream& out, vector<T>& a) {bool first = true;for(auto &x : a) {if(!first) out << ' ';first = false;out << x;}return out;};

namespace Dark_Lord_Binoy {
inline void init() {
    ios::sync_with_stdio(false); 
    cin.tie(nullptr);

    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
}

#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_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
// order_of_key (k) : Number of items strictly smaller than k . O(logn)
// find_by_order(k) : K-th element in a set (counting from zero). O(logn)
// erase(k) : s.erase(s.find_by_order(s.order_of_key(k)));
template <typename T> 
using og_set = tree<T, null_type, greater_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;


int32_t main() {
    Dark_Lord_Binoy::init();

    int n;
    cin >> n;
    vector<int> a(n), pre(n, 0), suf(n, 0);
    o_set<int> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        pre[i] = s.order_of_key(a[i] + 1);
        s.insert(a[i]);
    }
    og_set<int> f;
    for (int i = n - 1; i >= 0; i--) {
        suf[i] = f.order_of_key(a[i] + 1);
        f.insert(a[i]);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if(pre[i] >= a[i] || suf[i] >= a[i]) {
            ans++;
        }
    }
    cout << ans << nl;

    dbg(_Time_);
    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:04
Judged At
2025-04-06 16:29:04
Judged By
Score
7
Total Time
1ms
Peak Memory
548.0 KiB