/ SeriousOJ /

Record Detail

Wrong Answer


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

Code

/*
 * Name : Md. Fahmidur Rahman Nafi
 * Date : 2025-04-06   Time : 21:26:11
 */

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define debug(x) cout << "Debug : " << x << endl;
const double PI = 2 * acos(0.0);
const int MOD = 1000000007;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector <ll> a(n);
    map <int,vector <int>> mp;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        mp[a[i]].push_back(i);
    }
    
    int cnt = 0;
    for (int i = 0; i < n; i++){
        int big = 0, small = 0;
        for (auto &j : mp){
            auto lst = j.second;
            int len = lst.size();
            int x = lower_bound(lst.begin(), lst.end(), i) - lst.begin();

            if (j.first >= a[i]){
                if (x < len){
                    big += len - x;
                }
            }

            if (j.first <= a[i]){
                if (x > 0){
                    small += x;
                }
            }
        }

        if (small >= a[i] || big >= a[i]){
            cnt++;
        }
    }

    cout << cnt << endl;
}

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 17:39:13
Judged At
2025-04-06 17:39:13
Judged By
Score
9
Total Time
1ms
Peak Memory
532.0 KiB