82182024-01-12 20:50:24madvirSzínes szobák (50 pont)cpp17Runtime error 0/5057ms33644 KiB
#include <iostream>
#include <set>

using namespace std;

int main() {
    int n, k, m, x, lep, el=0;
    cin >> n >> k >> m;
    int c[n+1];
    set<int> szin[k+1];
    
    for(int i=0; i<=n; i++) {
        cin >> x;
        szin[x].insert(i);
    }
    
    for(int i=1; i<=n; i++) {
        cin >> x >> lep;
        if(lep==1) {
            szin[x].erase(*szin[x].begin());
            if(*szin[x].rbegin()+1>n) {
                el++;
                szin[x].erase(*szin[x].rbegin());
            }
            szin[x].insert(*szin[x].rbegin()+1);
        }
        else {
            szin[x].erase(*szin[x].rbegin());
            if(*szin[x].begin()-1<=0) {
                el++;
                szin[x].erase(*szin[x].begin());
            }
            szin[x].insert(*szin[x].begin());
        }
    }
    
    cout << lep;
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Runtime error0/03ms1908 KiB
2Runtime error0/057ms21480 KiB
3Runtime error0/14ms3192 KiB
4Runtime error0/13ms3300 KiB
5Runtime error0/14ms3612 KiB
6Runtime error0/13ms3592 KiB
7Runtime error0/14ms3608 KiB
8Runtime error0/13ms3612 KiB
9Runtime error0/14ms3880 KiB
10Runtime error0/14ms4284 KiB
11Runtime error0/13ms4296 KiB
12Runtime error0/14ms4524 KiB
13Runtime error0/14ms5332 KiB
14Runtime error0/16ms6256 KiB
15Runtime error0/17ms6668 KiB
16Runtime error0/17ms6804 KiB
17Runtime error0/17ms6912 KiB
18Runtime error0/17ms6980 KiB
19Runtime error0/152ms16240 KiB
20Runtime error0/150ms17000 KiB
21Runtime error0/152ms17736 KiB
22Runtime error0/152ms18400 KiB
23Runtime error0/150ms19152 KiB
24Runtime error0/150ms20176 KiB
25Runtime error0/152ms20748 KiB
26Runtime error0/152ms21492 KiB
27Runtime error0/348ms30520 KiB
28Runtime error0/348ms31264 KiB
29Runtime error0/350ms31884 KiB
30Runtime error0/348ms32392 KiB
31Runtime error0/348ms33132 KiB
32Runtime error0/350ms33644 KiB
33Runtime error0/425ms24724 KiB
34Runtime error0/425ms25044 KiB