63252023-11-17 22:10:06horvathabelKártyajátékcpp17Accepted 30/3046ms7164 KiB
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vector<ll> q;
    priority_queue<ll,vector<ll>, greater<ll>> pq;
    for (int i=0; i<k;i++){
        ll a;
        cin>>a;
        q.push_back(a);
        pq.push(a);
    }
    int ans=0;
    for (int i=0; i<k;i++){
        bool cnt=0;
        ll most=q[i];
        while (!pq.empty() && pq.top()<most && pq.top()!=q[i]){
            cnt=1;
            pq.pop();
        }
        if (pq.top()==q[i]) pq.pop();
        ans+=cnt;
    }
    cout<<ans;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1828 KiB
2Accepted0/045ms5668 KiB
3Accepted1/13ms2336 KiB
4Accepted1/13ms2448 KiB
5Accepted1/13ms2660 KiB
6Accepted2/23ms3020 KiB
7Accepted2/23ms3096 KiB
8Accepted2/23ms2980 KiB
9Accepted1/123ms6352 KiB
10Accepted2/232ms6440 KiB
11Accepted3/329ms7036 KiB
12Accepted3/330ms6988 KiB
13Accepted1/146ms6904 KiB
14Accepted2/245ms7164 KiB
15Accepted3/343ms7124 KiB
16Accepted3/345ms7132 KiB
17Accepted3/343ms7124 KiB