#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 91029102, there are nn contestants participating in the Zhejiang NOI Qualifier. The ii-th contestant has intelligence aia_i and training amount bib_i. 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 xx, where xx is a non-negative integer. The performance of the ii-th contestant on problems with reverse selection index xx is aix+bia_ix+b_i. When xx is fixed, the rank of the ii-th person is the number of people whose performance is strictly greater than aix+bia_ix+b_i, plus one.

In the year 91029102, the size of the Zhejiang provincial team is mm, so only those with rank m\le m can enter the team. Note that when there are ties, the number of people who enter the team may be greater than mm.

It is not hard to see that a contestant’s rank depends heavily on xx. Now, Karen wants you to compute whether the ii-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 n,m(mn)n,m(m\leq n), representing the total number of contestants and the size of the Zhejiang provincial team.
The next nn lines each contain two integers ai,bia_i,b_i, representing each contestant’s attributes.

Output Format

Output one line with nn integers. If the ii-th contestant cannot enter the Zhejiang provincial team, output 1-1. Otherwise, output their best possible rank.

3 1
1 5
5 1
2 2
1 1 -1

Hint

Constraints

Explanation of Sample 1

When x=1x=1, the three contestants’ performances are 6,6,46,6,4. 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 x>1x>1, the second contestant’s performance is strictly better than the third contestant’s. When x=0x=0, the first contestant’s performance is strictly better than the third contestant’s. Therefore, no matter how xx is chosen, the third contestant has no way to enter the provincial team.

Constraints and Notes

Test Point nn mm Test Point nn mm
11 200\le 200 20\le 20 66 2×104\le 2\times 10^4 20\le 20
22 77
33 105\le 10^5 =1=1 88 105\le 10^5
44 2\le 2 99
55 1010

For 100%100\% of the data, 1ai1091\leq a_i \leq 10^9, 1bi10181\leq b_i \leq 10^{18}, and 1mn1\leq m \leq n.

For 100%100\% of the data, it is guaranteed that all contestants’ attributes are pairwise different, i.e., 1i<jn \forall 1\leq i < j \leq n, we have aiaja_i\neq a_j or bibjb_i\neq b_j.

Translated by ChatGPT 5