No.817 Coin donation
タグ : / 解いたユーザー数 197
作問者 :
Enjapma_kyopro
/ テスター :
tempura_pp
Problem Statement
In the Kingdom of Enjapma, $10^9$ types of coins circulate, from the $1$-yen coin to the $10^9$-yen coin. The values of all coins are integers.
There is an empty donation box. Being kind-hearted, you perform $N$ operations on this box.
In the $i$-th operation, you put $1$ coin of each type from the $A_i$-yen coin to the $B_i$-yen coin into the box.
After the $N$ operations are finished, among the coins in the box, which coin is the $K$-th cheapest in value?
Input
$N \ K$ $A_1$ $B_1$ $A_2$ $B_2$ : $A_N$ $B_N$
$1 \le N \le 10^5$
$1 \le K \le min(10^9 , $ the number of coins in the box at the end$)$
$1 \le A_i \le 10^9$
$1 \le B_i \le 10^9$
$A_i \le B_i$
All inputs are integers.
Output
Output the value of the $K$-th cheapest coin in the box after the operations are finished. Print a newline at the end.
Sample
Sample 1
Input
3 6
1 4
2 5
1 6
Output
3
The box contains the following: of the $1$-yen coin, $2$ coins; of the $2$-yen coin, $3$ coins; of the $3$-yen coin, $3$ coins; of the $4$-yen coin, $3$ coins; of the $5$-yen coin, $2$ coins; of the $6$-yen coin, $1$ coin.
Among these, the $6$-th cheapest coin is the $3$-yen coin.
Sample 2
Input
14 159265
35 897
932 3846
264 338
327 950288
419 716
939 9375
105 82097
49 44592
307 81640
628 6208998
6280 348253
4211 7067
982 14808
651 3282
Output
22509
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。