結果

問題 No.817 Coin donation
ユーザー brthyyjpbrthyyjp
提出日時 2021-05-25 22:51:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 1,655 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 81,280 KB
最終ジャッジ日時 2024-04-22 14:39:39
合計ジャッジ時間 4,207 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,968 KB
testcase_01 AC 40 ms
52,480 KB
testcase_02 AC 45 ms
57,728 KB
testcase_03 AC 47 ms
57,856 KB
testcase_04 AC 41 ms
51,968 KB
testcase_05 AC 74 ms
70,400 KB
testcase_06 AC 94 ms
76,288 KB
testcase_07 AC 95 ms
76,472 KB
testcase_08 AC 150 ms
79,872 KB
testcase_09 AC 97 ms
76,800 KB
testcase_10 AC 178 ms
81,152 KB
testcase_11 AC 177 ms
81,280 KB
testcase_12 AC 174 ms
80,896 KB
testcase_13 AC 40 ms
52,224 KB
testcase_14 AC 40 ms
52,096 KB
testcase_15 AC 40 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
AB = []
for i in range(n):
    a, b = map(int, input().split())
    AB.append((a, b))

def is_ok(x):
    cnt = 0
    for a, b in AB:
        if x < a:
            continue
        elif a <= x <= b:
            cnt += x-a+1
        else:
            cnt += b-a+1
    if cnt >= k:
        return True
    else:
        return False

ng = 0
ok = 10**9+1
while ng+1<ok:
    c = (ng+ok)//2
    if is_ok(c):
        ok = c
    else:
        ng = c
print(ok)
0