1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <bits/stdc++.h>
using namespace std;

int T[21];

priority_queue <pair <int , int>> Q;
int main(){
    int n, a, x = 10;
    cin >> n;
    for(int i = 1; i<=n; i++){
        string s;
        cin >> s >> a;
        if(s == "TAK"){
            Q.push({i*-1, a});
        }
    }
    for(int i = 0; i<10; i++){
        T[i] = Q.top().first*-1;
        Q.pop();
    }
    while(Q.size()>0 && x <20){
        if(Q.top().second < 2){
            T[x] = Q.top().first*-1;
            x++;
            Q.pop();
        }
        else{
            Q.pop();
        }
    }
    sort(T, T+20);
    for(int i = 0; i<20; i++){
        cout << T[i] << ' ';
    }

    return 0;
}