25272023-01-16 10:44:03AbbenceKártyajátékcpp17Wrong answer 21/3086ms7264 KiB
#include <iostream>
#include <vector>
#include <algorithm>

/*
OKTV 2022 II. forduló
*/

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;

    long interval_max = 1;
    bool wasPointInInterval = false;
    for(long i=1; 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
base21/30
1Accepted0/03ms1684 KiB
2Accepted0/086ms4600 KiB
3Accepted1/12ms2160 KiB
4Accepted1/12ms2368 KiB
5Accepted1/12ms2548 KiB
6Wrong answer0/23ms2672 KiB
7Accepted2/23ms2888 KiB
8Wrong answer0/22ms2988 KiB
9Wrong answer0/132ms4328 KiB
10Accepted2/246ms6220 KiB
11Accepted3/346ms6284 KiB
12Accepted3/346ms6084 KiB
13Wrong answer0/186ms4964 KiB
14Accepted2/286ms5652 KiB
15Accepted3/386ms7264 KiB
16Wrong answer0/386ms6436 KiB
17Accepted3/386ms6568 KiB