27192023-01-19 12:55:28gontermarkKártyajátékcpp17Accepted 30/3090ms6508 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool comp(long long i, long long j)
{
    return(i>j);
}

int main()
{
    long long n;
    int k;
    cin >> n >> k;
    long long maxsz=0;
    long long szam;
    vector<long long> lerak;
    vector<long long> felre;
    for(int i=0;i<k;i++)
    {
        cin >> szam;
        if(szam<maxsz) felre.push_back(szam);
        else
        {
            lerak.push_back(szam);
            maxsz=szam;
        }
    }
    int db=0;
    if(felre.size()>0)
    {
        sort(felre.begin(),felre.begin()+felre.size(),comp);
        for(int i=0;i<lerak.size();i++)
        {
            if(felre.size()>0 && felre.back()<lerak[i])
            {
                db++;
                while(felre.size()>0 && felre.back()<lerak[i])
                {
                    felre.pop_back();
                }
            }
        }
    }
    cout << db;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1684 KiB
2Accepted0/085ms3636 KiB
3Accepted1/12ms2212 KiB
4Accepted1/12ms2404 KiB
5Accepted1/12ms2476 KiB
6Accepted2/23ms2700 KiB
7Accepted2/22ms2924 KiB
8Accepted2/22ms2984 KiB
9Accepted1/132ms4216 KiB
10Accepted2/246ms6064 KiB
11Accepted3/341ms5788 KiB
12Accepted3/343ms5256 KiB
13Accepted1/190ms5604 KiB
14Accepted2/286ms6004 KiB
15Accepted3/382ms6508 KiB
16Accepted3/386ms5368 KiB
17Accepted3/385ms5604 KiB