#P3963. [TJOI2013] 奖学金
[TJOI2013] 奖学金
Description
There are students in Xiao Zhang's college. The -th student's score is , and the scholarship amount they would receive is .
You need to select students from these students to award scholarships. This mysterious person has a peculiar preference: he wants the median of the scores of the students who receive scholarships to be as large as possible, while their total scholarship amount must not exceed .
Input Format
The first line contains three integers, representing the number of students to select , the total number of students , and the maximum total scholarship amount , guaranteeing that is odd.
Lines through : each line contains two integers. The -th line contains the -th student's score and, if they are awarded a scholarship, the amount that needs to be given.
Output Format
Output one integer on a single line representing the answer. If the mysterious person's conditions cannot be met, output .
3 5 70
30 25
50 21
20 20
5 18
35 30
35
5 6 9
4 0
4 1
6 3
8 0
10 4
10 5
6
Hint
Sample 1 Explanation
Select three students with scores , , and , with a total scholarship amount of .
Constraints
- For of the testdata, it is guaranteed that , .
- For of the testdata, it is guaranteed that , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号