82202024-01-12 21:21:53mmatedKártyajátékcpp17Accepted 30/3068ms14556 KiB
#include <bits/stdc++.h>
using namespace std;
#define f(i,k,n) for(ll i=k; i<n; i++)
#define ll long long
const int inf = INT_MAX;

void solve()
{
    unsigned ll n,k;
    cin>>n>>k;
    unsigned ll a[k];
    set<unsigned ll> s;
    f(i,0,k)
    {    
        cin>>a[i];
        s.insert(a[i]);
    }
    int cnt=0;
    f(i,0,k)
    {
        if(s.lower_bound(a[i])!=s.end() && s.lower_bound(a[i])!=s.begin())
        {
            cnt++;
            s.erase(s.begin(),s.lower_bound(a[i]));
        }
        s.erase(a[i]);
    }
    cout<<cnt<<"\n";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)  solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1828 KiB
2Accepted0/064ms13028 KiB
3Accepted1/13ms2240 KiB
4Accepted1/13ms2328 KiB
5Accepted1/13ms2448 KiB
6Accepted2/23ms2848 KiB
7Accepted2/23ms2792 KiB
8Accepted2/23ms2792 KiB
9Accepted1/137ms10452 KiB
10Accepted2/256ms14008 KiB
11Accepted3/350ms14336 KiB
12Accepted3/352ms14288 KiB
13Accepted1/167ms14340 KiB
14Accepted2/268ms14360 KiB
15Accepted3/363ms14468 KiB
16Accepted3/364ms14556 KiB
17Accepted3/363ms14544 KiB