結果

問題 No.817 Coin donation
コンテスト
ユーザー ああいい
提出日時 2022-01-27 15:07:35
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 104 ms / 2,000 ms
+ 16µs
コード長 454 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 67 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 88,596 KB
最終ジャッジ日時 2026-10-07 18:42:22
合計ジャッジ時間 2,534 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,K = map(int,input().split())

edge = []
for _ in range(N):
    a,b = map(int,input().split())
    edge.append((a,b))
    
def check(x):
    count = 0
    for a,b in edge:
        if a <= x <= b:
            count += x - a + 1
        elif x > b:
            count += b - a + 1
    return count >= K
start = 0
end = 10 ** 9
while end - start > 1:
    mid = (end + start) // 2
    if check(mid):
        end = mid
    else:
        start = mid
print(end)
0