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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> finalists;
    string eligible;
    int prev_finals;

    for (int i = 1; finalists.size() < 20; ++i)
    {
        cin >> eligible >> prev_finals;
        if (eligible != "TAK") continue;
        if (finalists.size() < 10 || prev_finals < 2) finalists.push_back(i);
    }

    for (int e : finalists) cout << e << ' ';
}