結果

問題 No.817 Coin donation
ユーザー 👑 rin204rin204
提出日時 2022-02-21 00:37:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 87,324 KB
最終ジャッジ日時 2023-09-11 21:13:02
合計ジャッジ時間 3,939 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,404 KB
testcase_01 AC 77 ms
71,516 KB
testcase_02 AC 83 ms
75,460 KB
testcase_03 AC 83 ms
75,444 KB
testcase_04 AC 77 ms
71,460 KB
testcase_05 AC 108 ms
77,168 KB
testcase_06 AC 122 ms
78,028 KB
testcase_07 AC 124 ms
77,848 KB
testcase_08 AC 173 ms
83,360 KB
testcase_09 AC 125 ms
77,988 KB
testcase_10 AC 201 ms
87,324 KB
testcase_11 AC 200 ms
87,176 KB
testcase_12 AC 198 ms
87,100 KB
testcase_13 AC 75 ms
71,136 KB
testcase_14 AC 75 ms
71,424 KB
testcase_15 AC 74 ms
71,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def ok(x):
    ret = 0
    for a, b in ab:
        if x < a:
            continue
        else:
            ret += min(b, x) - a + 1
            if ret >= k:
                return True
    return False

l = 0
r = 10 ** 9
while r - l > 1:
    mid = (l + r) // 2
    if ok(mid):
        r = mid
    else:
        l = mid
        
print(r)
0