結果

問題 No.817 Coin donation
ユーザー maspymaspy
提出日時 2020-02-06 12:23:42
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 510 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 11,748 KB
実行使用メモリ 44,756 KB
最終ジャッジ日時 2023-10-25 22:26:28
合計ジャッジ時間 10,961 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 446 ms
42,180 KB
testcase_01 AC 443 ms
42,188 KB
testcase_02 AC 444 ms
42,184 KB
testcase_03 AC 443 ms
42,180 KB
testcase_04 AC 442 ms
42,188 KB
testcase_05 AC 444 ms
42,180 KB
testcase_06 AC 448 ms
42,180 KB
testcase_07 AC 475 ms
42,180 KB
testcase_08 AC 510 ms
43,704 KB
testcase_09 AC 448 ms
42,184 KB
testcase_10 AC 467 ms
44,756 KB
testcase_11 AC 468 ms
44,756 KB
testcase_12 AC 464 ms
44,756 KB
testcase_13 AC 443 ms
42,184 KB
testcase_14 AC 444 ms
42,184 KB
testcase_15 AC 445 ms
42,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

data = np.fromstring(read(), np.int64, sep=' ')

N, K = data[:2]
AB = data[2:]
A = AB[::2]
B = AB[1::2]

def f(x):
    """count coins <= x"""
    return np.maximum(0, 1 + np.minimum(x, B) - A).sum()

left = 0
right = 10 ** 9
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= K:
        right = x
    else:
        left = x

print(right)
0