luogu#P1309. [NOIP 2011 普及组] 瑞士轮
[NOIP 2011 普及组] 瑞士轮
Background
In head-to-head competitive sports such as table tennis, badminton, and chess, the most common formats are knockout and round-robin. The former requires fewer matches and each match is tense and exciting, but it is more random. The latter is fairer and less random, but the process is often very long.
The Swiss-system format introduced in this problem is named after its earliest use in an international chess tournament held in Switzerland in 1895. It can be seen as a compromise between knockout and round-robin: it ensures stability while keeping the schedule from becoming too long.
Problem Description
players, numbered , play rounds. Before each round starts, and after all matches are finished, players are ranked in descending order by total points. A player's total points equal the initial points before round plus the sum of points earned in all matches already played. If the total points are the same, the player with the smaller id ranks ahead.
The pairings of each round depend on the ranking at the start of that round: rank vs rank , rank vs rank , ..., rank vs rank , ..., rank vs rank . The winner of each match gets point and the loser gets points. That is, except for the first round, the arrangements of the other rounds cannot be determined in advance; they depend on the players' performances in previous matches.
Given each player's initial points and strength value, compute the id of the player ranked -th after rounds. We assume all strength values are pairwise distinct, and in every match the player with the higher strength always wins.
Input Format
The first line contains three positive integers , separated by single spaces, indicating there are players, rounds, and we are interested in the -th place.
The second line contains non-negative integers , separated by single spaces, where denotes the initial points of the player with id .
The third line contains positive integers , separated by single spaces, where denotes the strength value of the player with id .
Output Format
Output a single integer: the id of the player ranked -th after rounds.
2 4 2
7 6 6 7
10 5 20 15
1
Hint
Sample Explanation:

Constraints:
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , , , .
NOIP 2011 Junior Problem 3.
Translated by ChatGPT 5