結果

問題 No.817 Coin donation
ユーザー 👑 H20H20
提出日時 2021-09-22 11:26:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 501 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 90,300 KB
最終ジャッジ日時 2023-09-18 07:35:33
合計ジャッジ時間 3,150 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,452 KB
testcase_01 AC 69 ms
71,428 KB
testcase_02 AC 73 ms
75,276 KB
testcase_03 AC 74 ms
75,488 KB
testcase_04 AC 70 ms
71,616 KB
testcase_05 AC 108 ms
78,052 KB
testcase_06 AC 123 ms
77,976 KB
testcase_07 AC 129 ms
78,096 KB
testcase_08 AC 194 ms
85,920 KB
testcase_09 AC 129 ms
80,004 KB
testcase_10 AC 231 ms
90,292 KB
testcase_11 AC 219 ms
90,212 KB
testcase_12 AC 231 ms
90,300 KB
testcase_13 AC 69 ms
71,588 KB
testcase_14 AC 72 ms
71,520 KB
testcase_15 AC 69 ms
71,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
AB = []
for i in range(N):
    AB.append(list(map(int,input().split())))

def is_ok(v):
    temp = 0
    for a,b in AB:
        temp+=max(0,min(v,b)-a+1)
    return temp>=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
ok = meguru_bisect(0,10**9+100)
ans = 0
for a,b in AB:
    if a<=ok<=b:
        ans = max(ans,min(b,ok))

print(ans)
0