結果

問題 No.817 Coin donation
ユーザー H3PO4H3PO4
提出日時 2021-02-12 09:03:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 412 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 10,592 KB
実行使用メモリ 21,296 KB
最終ジャッジ日時 2023-09-26 07:56:25
合計ジャッジ時間 4,009 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,768 KB
testcase_01 AC 16 ms
7,800 KB
testcase_02 AC 17 ms
7,776 KB
testcase_03 AC 18 ms
7,784 KB
testcase_04 AC 16 ms
7,784 KB
testcase_05 AC 28 ms
8,176 KB
testcase_06 AC 70 ms
9,816 KB
testcase_07 AC 83 ms
10,296 KB
testcase_08 AC 289 ms
17,320 KB
testcase_09 AC 95 ms
10,628 KB
testcase_10 AC 410 ms
21,284 KB
testcase_11 AC 410 ms
21,296 KB
testcase_12 AC 412 ms
21,272 KB
testcase_13 AC 15 ms
7,852 KB
testcase_14 AC 16 ms
7,764 KB
testcase_15 AC 16 ms
7,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


def cnt(x):
    res = 0
    for a, b in AB:
        if a <= x:
            res += min(b, x) - a + 1
    return res


# bisect
l, r = 0, 10 ** 9 + 1
while r - l > 1:
    m = (r + l) // 2
    if cnt(m) < K:
        l = m
    else:
        r = m
print(r)
0