結果

問題 No.817 Coin donation
ユーザー rlangevinrlangevin
提出日時 2023-03-10 08:54:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 492 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 81,604 KB
実行使用メモリ 76,976 KB
最終ジャッジ日時 2023-10-18 06:37:07
合計ジャッジ時間 3,523 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,332 KB
testcase_01 AC 38 ms
53,332 KB
testcase_02 AC 41 ms
59,036 KB
testcase_03 AC 42 ms
59,036 KB
testcase_04 AC 38 ms
53,332 KB
testcase_05 AC 54 ms
66,228 KB
testcase_06 AC 59 ms
70,332 KB
testcase_07 AC 61 ms
72,380 KB
testcase_08 AC 88 ms
76,452 KB
testcase_09 AC 63 ms
72,960 KB
testcase_10 AC 102 ms
76,976 KB
testcase_11 AC 102 ms
76,972 KB
testcase_12 AC 102 ms
76,972 KB
testcase_13 AC 38 ms
53,332 KB
testcase_14 AC 38 ms
53,332 KB
testcase_15 AC 38 ms
53,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

def check(m):
    cnt = 0
    for i in range(N):
        if m > B[i]:
            cnt += max(0, B[i] - A[i] + 1)
        else:
            cnt += max(0, m - A[i])
    return cnt < K

N, K = map(int, readline().split())
A, B = [0] * N, [0] * N
for i in range(N):
    A[i], B[i] = map(int, readline().split())

yes = 0
no = 10 ** 10
while no - yes != 1:
    mid = (yes + no)//2
    if check(mid):
        yes = mid
    else:
        no = mid
print(yes)
0