27162023-01-19 12:44:35AbbenceKártyajátékcpp17Accepted 30/3085ms7136 KiB
#include <iostream>
#include <vector>
#include <algorithm>

/*
OKTV 2022 II. fordulo
*/

using namespace std;

int main()
{
    long n, k;
    cin >> n >> k;
    long hand[k];
    for(long i=0; i<k; i++){
        cin >> hand[i];
    }
    vector<long> played;
    played.push_back(hand[0]);
    for(long i=1; i<k; i++){
        if(hand[i] > played.back()){
            played.push_back(hand[i]);
        }
    }
    long playedSize = played.size();

    sort(hand,hand+k);

    long points = 0;

    if(playedSize == 1){
        if(k > 1) points = 1;
        else points = 0;
    }
    else{
        long interval_max = 0; //index
        bool wasPointInInterval = false;
        for(long i=0; i<k && interval_max < playedSize; i++){
            if(hand[i] != played.at(interval_max)){
                if(!wasPointInInterval){
                    points++;
                    wasPointInInterval = true;
                }
            }
            else{
                interval_max++;
                wasPointInInterval = false;
            }
        }
    }

    cout << points << endl;

    return 0;
}
/*
25 7
1 8 3 15 4 20 16


1 3 4 8 15 16 20
*/
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1812 KiB
2Accepted0/083ms4736 KiB
3Accepted1/12ms2404 KiB
4Accepted1/12ms2540 KiB
5Accepted1/12ms2672 KiB
6Accepted2/23ms2884 KiB
7Accepted2/22ms2968 KiB
8Accepted2/22ms2972 KiB
9Accepted1/130ms4312 KiB
10Accepted2/245ms5912 KiB
11Accepted3/345ms5920 KiB
12Accepted3/346ms6048 KiB
13Accepted1/182ms4980 KiB
14Accepted2/282ms5612 KiB
15Accepted3/382ms7136 KiB
16Accepted3/385ms6320 KiB
17Accepted3/382ms6364 KiB