27152023-01-19 12:32:36AbbenceKártyajátékcpp17Wrong answer 18/3082ms7548 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]);
        }
    }

    sort(hand,hand+k);

    long points = 0;

    if(played.size() == 1){
        if(k > 1) points = 1;
        else points = 0;
    }
    else{
        long interval_max = 1; //index
        bool wasPointInInterval = false;
        for(long i=0; i<k; 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
base18/30
1Accepted0/03ms1808 KiB
2Wrong answer0/082ms4728 KiB
3Wrong answer0/12ms2208 KiB
4Accepted1/12ms2308 KiB
5Accepted1/12ms2404 KiB
6Wrong answer0/22ms2628 KiB
7Accepted2/23ms2852 KiB
8Wrong answer0/23ms3076 KiB
9Wrong answer0/130ms4652 KiB
10Accepted2/245ms6124 KiB
11Accepted3/343ms6136 KiB
12Accepted3/345ms5888 KiB
13Wrong answer0/182ms5176 KiB
14Wrong answer0/282ms5916 KiB
15Accepted3/382ms7548 KiB
16Wrong answer0/382ms6628 KiB
17Accepted3/382ms6704 KiB