結果

問題 No.817 Coin donation
ユーザー kohei2019
提出日時 2022-04-18 22:45:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 81,068 KB
最終ジャッジ日時 2024-12-30 06:00:31
合計ジャッジ時間 3,264 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
lsAB = []
for i in range(N):
    A,B = map(int,input().split())
    lsAB.append((A,B))

def is_ok(arg):
    cnt = 0
    for i in range(N):
        cnt += max(0,min(arg,lsAB[i][1])-lsAB[i][0]+1)
    return cnt >= K
def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
print(meguru_bisect(0,10**18+1))
0