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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <string>
#include <cassert>
#include <vector>

// Config selector:
// 1 == Debug
// 0 == Release
#if 0

// Debug config
#define ASSERT(expr) assert(expr)
#define DBG(expr) expr

#else

// Release config
#define ASSERT(expr) do {} while (0)
#define DBG(expr) do {} while (0)

#endif

template<class T>
std::ostream & operator<<(std::ostream & out, std::vector<T> const & vec)
{
	for (int i = 0; i < (int)vec.size(); ++i)
	{
		out << vec[i];
		if (i != (int)vec.size() - 1)
			out << ' ';
	}
	return out;
}

struct Participant
{
	int times_in_final;
	bool can_be_in_final;
};

std::vector<int> compute_participants_in_final(std::vector<Participant> const & vec)
{
	std::vector<int> result;
	result.reserve(20);

	for (int i = 0; i < (int)vec.size() && (int)result.size() < 20; ++i)
	{
		Participant const & p = vec[i];
		if (p.can_be_in_final)
		{
			DBG(std::cout << "considering participant idx " << i << " times in final: " << p.times_in_final << '\n');
			if ((int)result.size() < 10 || p.times_in_final < 2)
				result.push_back(i + 1);
		}
		else
		{
			DBG(std::cout << "skipping participant idx " << i << " who cannot be in final\n");
		}
	}

	return result;
}

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

	int n;
	std::cin >> n;

	std::vector<Participant> participants;
	participants.reserve(n);
	std::string str;
	for (int i = 0; i < n; ++i)
	{
		int x;
		std::cin >> str >> x;
		ASSERT(str == "TAK" || str == "NIE");
		participants.push_back({x, str == "TAK"});
	}

	std::cout << compute_participants_in_final(participants) << '\n';
}