結果

問題 No.817 Coin donation
ユーザー lllllll88938494lllllll88938494
提出日時 2023-04-28 13:53:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 388 bytes
コンパイル時間 448 ms
コンパイル使用メモリ 82,044 KB
実行使用メモリ 86,604 KB
最終ジャッジ日時 2024-11-17 14:18:05
合計ジャッジ時間 3,388 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]


def  check(a):
    cnt=0
    for i,j in x:
        if i <= a:
            cnt += min(a,j) - i + 1
    if cnt < k:
        return False
    else:
        return True

ng = 0
ok = 10**9

while ok-ng > 1:
    mid = (ok + ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid

print(ok)
0