/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 328.0 KiB
#3 Accepted 1ms 584.0 KiB
#4 Accepted 1ms 588.0 KiB
#5 Wrong Answer 1ms 540.0 KiB

Code

        #include<bits/stdc++.h>
        using namespace std;
        #define endl '\n'
        #define ll long long int
        #define vv vector<long long>
        #define dq deque<long long>
        #define mpp map<long long,long long>
        #define ms multiset<long long>
        #define ss set<long long>
        #define vpp vector<pair<long long, long long>>
        #define MOD 1000000007
        #define YES cout<<"YES"<<endl
        #define NO cout<<"NO"<<endl
        #define all(a) a.begin(),a.end()
        #define sort_rev(a) sort(a.rbegin(),a.rend())
        #define all_n for(int i=0;i<n;i++)
        #define print(a) for(auto it:a)cout<<it<<" "
        #define print_pair(a) for(auto it:a)cout<<it.first<<" "<<it.second<<endl
        #define scan(a,n) for(int i=0;i<n;i++)cin>>a[i]
        void requisite(){
            ios::sync_with_stdio(false);
            cin.tie(nullptr);cout.tie(nullptr);
        }
        void solve(){
              ll n;cin>>n;
              vv v(n);scan(v,n);
              ms m1,m2;
              ll count=0;
            for (int i = 0; i < n; ++i) {
                m1.insert(v[i]);
            }
            for (int i = 0; i < n; ++i) {
                auto it=m1.lower_bound(v[i]);
                ll d1= distance(it,m1.end());
                it=m2.lower_bound(v[i]);
                ll d2= distance(it,m2.end());
                if (d1>=v[i] or d2>=v[i])count++;
                it = m1.find(v[i]);
                if (it != m1.end()) {
                    m1.erase(it);
                }
                m2.insert(v[i]);
            }
            cout<<count<<endl;
        }
        int main() {
            requisite();
            ll t=1;
//            cin>>t;
            while (t--){
                solve();
            }
            return 0;
        }

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 06:31:38
Judged At
2025-04-08 06:31:38
Judged By
Score
3
Total Time
1ms
Peak Memory
588.0 KiB