#P11913. PA 2025 Finalist Selection
PA 2025 Finalist Selection
PA 2025 Finalist Selection
The PA 2025 contest has an online round with n participants ranked from 1 to n (the i-th participant has rank i). Only participants who are Polish citizens or who study, work, or reside in Poland and who have not withdrawn are eligible for the final. From those eligible, 20 finalists will be selected based on the following rules:
- The first 10 finalists are chosen in order of their ranking from the eligible pool.
- The next 10 finalists are chosen in order of ranking from the remaining eligible participants, but excluding those who have participated in the PA finals at least twice before (i.e. if the number of previous participations is at least 2).
It is guaranteed that after removing ineligible and withdrawn participants, and applying the above rules, exactly 20 finalists can be selected.
Note: Even if a candidate has participated in the finals at least twice, they can still be selected if they are among the top 10 eligible candidates.
inputFormat
The first line contains an integer n (n ≥ 20) — the number of participants in the PA 2025 online contest.
Each of the following n lines contains two space-separated integers:
- The first integer is the eligibility flag (1 if the candidate is eligible to participate in the final, 0 otherwise).
- The second integer is the number of times the candidate has participated in previous PA finals.
The candidates are given in increasing order of their rank (i.e. the first candidate has rank 1, the second rank 2, and so on).
outputFormat
Output the ranking numbers of the 20 selected finalists, one per line, in the order they are chosen (which corresponds to increasing order of rank).
sample
25
1 3
1 0
1 1
1 2
1 5
1 0
1 1
1 7
1 0
1 1
1 2
1 0
1 1
1 2
1 0
1 1
1 0
1 1
1 0
1 0
1 0
1 1
0 0
1 1
1 0
1
2
3
4
5
6
7
8
9
10
12
13
15
16
17
18
19
20
21
22
</p>