結果

問題 No.817 Coin donation
ユーザー OKCH3COOHOKCH3COOH
提出日時 2019-11-09 10:01:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 437 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 21,376 KB
最終ジャッジ日時 2023-10-13 06:58:58
合計ジャッジ時間 3,608 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,844 KB
testcase_01 AC 15 ms
7,808 KB
testcase_02 AC 15 ms
7,832 KB
testcase_03 AC 16 ms
7,796 KB
testcase_04 AC 15 ms
7,852 KB
testcase_05 AC 27 ms
8,572 KB
testcase_06 AC 71 ms
10,004 KB
testcase_07 AC 86 ms
10,340 KB
testcase_08 AC 302 ms
17,412 KB
testcase_09 AC 99 ms
10,716 KB
testcase_10 AC 428 ms
21,376 KB
testcase_11 AC 437 ms
21,316 KB
testcase_12 AC 437 ms
21,312 KB
testcase_13 AC 15 ms
7,804 KB
testcase_14 AC 16 ms
7,772 KB
testcase_15 AC 15 ms
7,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
coins = []

for _ in range(N):
    A, B = map(int, input().split())
    coins.append((A, B + 1))

def isOk(m):
    cnt = 0
    for a, b in coins:
        if a >= m:
            continue
        cnt += min(m, b) - a
    return cnt < K

ok = 0
ng = 10**9 + 1
while ng - ok > 1:
    mid = (ok + ng) // 2
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(ok)
0