結果

問題 No.817 Coin donation
ユーザー kurimupykurimupy
提出日時 2020-06-15 17:37:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 82,232 KB
最終ジャッジ日時 2024-07-03 11:29:59
合計ジャッジ時間 2,795 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#coins donation
from collections import deque
N, K = map(int, input().split())
d = []
for i in range(N):
    a, b = map(int, input().split())
    d.append((a, b))
#二部探索


def cnt(X):
    res = 0
    for a, b in d:
        if X >= a:
            res += min(X-a+1, b-a+1)
    return res


l = 0
r = 10**10
#l :::: cnt(X)<K
#r :::: cnt(X)>=K

while r-l > 1:
    M = (r+l)//2
    if cnt(M) >= K:
        r = M
    else:
        l = M
print(r)


0