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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

#ifdef GGDEBUG
#define dbg printf
#else
#define dbg // dbg
#endif

struct Zawodnik {
    bool chce;
    int finaly;
};

int main() {
    int n;
    cin >> n;

    vector<pair<int, int>> players;
    vector<int> finals;

    for (int i = 0; i < n; i++) {
        string s;
        int x;
        cin >> s >> x;
        bool wants = (s == "TAK");
        if (wants) {
            players.push_back(make_pair(i + 1, x));
        }
    }

    for (auto &p : players) {
        if (finals.size() == 10) {
            break;
        }
        finals.push_back(p.first);
        // already in finals, block it
        p.second = 20;
    }

    dbg("finals.size() = %d\n", finals.size());

    for (auto &p : players) {
        if (finals.size() == 20) {
            break;
        }
        if (p.second < 2) {
            finals.push_back(p.first);
        }
    }

    for (int x : finals) {
        printf("%d ", x);
    }
    printf("\n");

    return 0;
}