#P5328. [ZJOI2019] 浙江省选
[ZJOI2019] 浙江省选
Description
Kyuukawa Karen is a girl who likes to create problems. This problem is a hardcore simulation problem about the Zhejiang NOI Qualifier.
In the year , there are contestants participating in the Zhejiang NOI Qualifier. The -th contestant has intelligence and training amount . As the problem setter, Karen can freely choose whether this set of problems is more “pattern-based” or more “intelligence-based”. For example, the problems in ZJOI 2018 were more intelligence-based, while this year’s problems are more pattern-based.
To measure the style of a set of problems quantitatively, Karen defines the reverse selection index , where is a non-negative integer. The performance of the -th contestant on problems with reverse selection index is . When is fixed, the rank of the -th person is the number of people whose performance is strictly greater than , plus one.
In the year , the size of the Zhejiang provincial team is , so only those with rank can enter the team. Note that when there are ties, the number of people who enter the team may be greater than .
It is not hard to see that a contestant’s rank depends heavily on . Now, Karen wants you to compute whether the -th contestant can possibly enter the Zhejiang provincial team. If possible, what is their best possible rank.
Input Format
The first line contains two integers , representing the total number of contestants and the size of the Zhejiang provincial team.
The next lines each contain two integers , representing each contestant’s attributes.
Output Format
Output one line with integers. If the -th contestant cannot enter the Zhejiang provincial team, output . Otherwise, output their best possible rank.
3 1
1 5
5 1
2 2
1 1 -1
Hint
Constraints
Explanation of Sample 1
When , the three contestants’ performances are . At this time, the first two contestants are tied for 1st place, and both can enter the provincial team. The third contestant ranks 3rd and cannot enter.
When , the second contestant’s performance is strictly better than the third contestant’s. When , the first contestant’s performance is strictly better than the third contestant’s. Therefore, no matter how is chosen, the third contestant has no way to enter the provincial team.
Constraints and Notes
| Test Point | Test Point | ||||
|---|---|---|---|---|---|
For of the data, , , and .
For of the data, it is guaranteed that all contestants’ attributes are pairwise different, i.e., , we have or .
Translated by ChatGPT 5
京公网安备 11011102002149号