結果

問題 No.817 Coin donation
ユーザー c-yanc-yan
提出日時 2021-01-17 03:28:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 10,824 KB
実行使用メモリ 21,320 KB
最終ジャッジ日時 2023-08-19 09:27:22
合計ジャッジ時間 3,744 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,740 KB
testcase_01 AC 15 ms
7,860 KB
testcase_02 AC 14 ms
7,796 KB
testcase_03 AC 15 ms
7,744 KB
testcase_04 AC 15 ms
7,768 KB
testcase_05 AC 21 ms
8,540 KB
testcase_06 AC 41 ms
9,852 KB
testcase_07 AC 48 ms
10,324 KB
testcase_08 AC 153 ms
17,356 KB
testcase_09 AC 55 ms
10,716 KB
testcase_10 AC 213 ms
21,312 KB
testcase_11 AC 214 ms
21,272 KB
testcase_12 AC 212 ms
21,320 KB
testcase_13 AC 15 ms
7,784 KB
testcase_14 AC 15 ms
7,776 KB
testcase_15 AC 15 ms
7,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin

readline = stdin.readline

N, K = map(int, readline().split())
AB = [tuple(map(int, readline().split())) for _ in range(N)]


def is_ok(m):
    t = 0
    for A, B in AB:
        if m < A:
            continue
        if m >= B:
            t += B - A + 1
        else:
            t += m - A + 1
    return t >= K


ok = 10 ** 9 + 1
ng = 0
while ok - ng > 1:
    m = ng + (ok - ng) // 2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)
0