#P1309. [NOIP 2011 普及组] 瑞士轮

[NOIP 2011 普及组] 瑞士轮

Description

2×N2 \times N players, numbered 12×N1 \sim 2 \times N, play RR 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 11 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 11 vs rank 22, rank 33 vs rank 44, ..., rank 2×K12 \times K - 1 vs rank 2×K2 \times K, ..., rank 2×N12 \times N - 1 vs rank 2×N2 \times N. The winner of each match gets 11 point and the loser gets 00 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 QQ-th after RR 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 N,R,QN, R, Q, separated by single spaces, indicating there are 2×N2 \times N players, RR rounds, and we are interested in the QQ-th place.

The second line contains 2×N2 \times N non-negative integers s1,s2,,s2×Ns_1, s_2, \dots, s_{2 \times N}, separated by single spaces, where sis_i denotes the initial points of the player with id ii.

The third line contains 2×N2 \times N positive integers w1,w2,,w2×Nw_1, w_2, \dots, w_{2 \times N}, separated by single spaces, where wiw_i denotes the strength value of the player with id ii.

Output Format

Output a single integer: the id of the player ranked QQ-th after RR rounds.

2 4 2 
7 6 6 7 
10 5 20 15 

1

Hint

Sample Explanation:

Constraints:

  • For 30%30\% of the testdata, 1N1001 \le N \le 100.
  • For 50%50\% of the testdata, 1N100001 \le N \le 10000.
  • For 100%100\% of the testdata, 1N1051 \le N \le 10^5, 1R501 \le R \le 50, 1Q2×N1 \le Q \le 2 \times N, 0s1,s2,,s2×N1080 \le s_1, s_2, \dots, s_{2 \times N} \le 10^8, 1w1,w2,,w2×N1081 \le w_1, w_2, \dots, w_{2 \times N} \le 10^8.

NOIP 2011 Junior Problem 3.

Translated by ChatGPT 5