結果

問題 No.817 Coin donation
ユーザー brthyyjpbrthyyjp
提出日時 2021-05-25 22:51:50
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 1,133 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 82,972 KB
最終ジャッジ日時 2023-08-04 16:34:10
合計ジャッジ時間 3,549 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,260 KB
testcase_01 AC 66 ms
71,020 KB
testcase_02 AC 67 ms
75,360 KB
testcase_03 AC 70 ms
75,216 KB
testcase_04 AC 68 ms
71,380 KB
testcase_05 AC 89 ms
76,996 KB
testcase_06 AC 100 ms
77,708 KB
testcase_07 AC 103 ms
77,960 KB
testcase_08 AC 142 ms
81,640 KB
testcase_09 AC 107 ms
78,104 KB
testcase_10 AC 164 ms
82,936 KB
testcase_11 AC 171 ms
82,720 KB
testcase_12 AC 164 ms
82,972 KB
testcase_13 AC 63 ms
71,228 KB
testcase_14 AC 64 ms
71,320 KB
testcase_15 AC 62 ms
71,300 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