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
#include "iostream"
#include "sstream"
#include "vector"

struct Participant {
    int index;
    int finals;

    Participant(int _index, int _finals) : index(_index), finals(_finals) {}
};


int main() {
    int n;
    std::cin >> n;
    std::string line;
    std::getline (std::cin,line);
    std::vector<Participant> participants;
    for (int i = 1; i <= n; i++) {
        int how_many;
        std::string eligible;
        std::getline (std::cin,line);
        std::stringstream s(line);
        s >> eligible >> how_many;
        if (eligible == "TAK") {
            participants.emplace_back(i, how_many);
        }
    }

    std::vector<int> finalists;
    for (int i = 0; i < 10; i++) {
        finalists.push_back(participants[i].index);
    }
    for (int i = 10; i < participants.size(); i++) {
        if (participants[i].finals < 2) {
            finalists.push_back(participants[i].index);
        }
        if (finalists.size() == 20) {
            break;
        }
    }

    for (const auto f: finalists) {
        std::cout << f << " ";
    }
    std::cout << '\n';
    return 0;
}