27182023-01-19 12:52:55gontermarkKártyajátékcpp17Wrong answer 18/3089ms6476 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool comp(int i, int 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
base18/30
1Accepted0/03ms1812 KiB
2Wrong answer0/085ms3792 KiB
3Accepted1/12ms2208 KiB
4Accepted1/12ms2412 KiB
5Accepted1/12ms2488 KiB
6Accepted2/22ms2504 KiB
7Accepted2/22ms2632 KiB
8Accepted2/23ms2832 KiB
9Accepted1/132ms4020 KiB
10Accepted2/245ms5648 KiB
11Accepted3/341ms5460 KiB
12Accepted3/343ms4908 KiB
13Wrong answer0/189ms5384 KiB
14Wrong answer0/286ms5896 KiB
15Wrong answer0/382ms6476 KiB
16Wrong answer0/385ms5064 KiB
17Wrong answer0/383ms5564 KiB