81232024-01-12 14:06:52AblablablaKártyajátékcpp17Accepted 30/3046ms20064 KiB
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ll;
typedef pair<ll, int> pii;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll n, k;
    cin >> n >> k;

    vector<bool> marVolt(k, 0);
    vector<ll> eredeti(k, 0);
    priority_queue<pii, vector<pii>, greater<pii>> sorrend;

    for(int i = 0; i < k; i++){
        cin >> eredeti[i];
        sorrend.push({eredeti[i], i});
    }

    int valasz = 0;
    for(int i = 0; i < k; i++){
        if(marVolt[i]) continue;

        int ki = 0;
        while(!sorrend.empty() && sorrend.top().first < eredeti[i]){
            if(!marVolt[sorrend.top().second]){
                marVolt[sorrend.top().second] = 1;
                ki++;
            }

            sorrend.pop();
        }

        if(ki){
            valasz++;
        }

        marVolt[i] = 1;
    }

    cout << valasz << "\n";
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1828 KiB
2Accepted0/046ms9264 KiB
3Accepted1/13ms4056 KiB
4Accepted1/13ms4260 KiB
5Accepted1/13ms4472 KiB
6Accepted2/23ms4832 KiB
7Accepted2/23ms5040 KiB
8Accepted2/23ms5224 KiB
9Accepted1/125ms10212 KiB
10Accepted2/235ms10848 KiB
11Accepted3/332ms11136 KiB
12Accepted3/334ms10940 KiB
13Accepted1/145ms12512 KiB
14Accepted2/245ms14452 KiB
15Accepted3/343ms16496 KiB
16Accepted3/345ms18356 KiB
17Accepted3/345ms20064 KiB