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
#include <iostream>
#include <string>

using namespace std;

int main() {
    std::ios_base::sync_with_stdio(false);
    int n;

    const string tak = "TAK";
    string s;

    int x;

    constexpr int FINALS_LIMIT = 2;
    constexpr int FINALIST_NUMBER_GOAL = 20;
    int numberOfFinalistSoFar = 0;
    bool stop = false;

    cin >> n;
    for (int participantNumber = 1; participantNumber <= n; participantNumber++) {
        cin >> s >> x;
        if ((numberOfFinalistSoFar * 2 < FINALIST_NUMBER_GOAL && tak == s) || (!stop && tak == s && x < FINALS_LIMIT)) {
            cout << participantNumber;
            numberOfFinalistSoFar++;
            if (FINALIST_NUMBER_GOAL == numberOfFinalistSoFar) {
                stop = true;
                cout << "\n";
            } else {
                cout << " ";
            }
        }
    }
}