結果

問題 No.817 Coin donation
ユーザー neterukunneterukun
提出日時 2019-06-14 01:02:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 764 ms / 2,000 ms
コード長 441 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 30,464 KB
最終ジャッジ日時 2024-04-24 02:01:10
合計ジャッジ時間 4,830 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,624 KB
testcase_01 AC 29 ms
10,624 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 33 ms
10,624 KB
testcase_04 AC 32 ms
10,624 KB
testcase_05 AC 51 ms
11,136 KB
testcase_06 AC 123 ms
13,184 KB
testcase_07 AC 144 ms
13,824 KB
testcase_08 AC 518 ms
24,320 KB
testcase_09 AC 165 ms
14,464 KB
testcase_10 AC 749 ms
30,464 KB
testcase_11 AC 764 ms
30,336 KB
testcase_12 AC 746 ms
30,336 KB
testcase_13 AC 32 ms
10,752 KB
testcase_14 AC 30 ms
10,624 KB
testcase_15 AC 30 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

def solve(mid):
    ans = 0
    for i in range(n):
        if info[i][0] < mid:
            ans += (min(mid, info[i][1]+1) - info[i][0])
    if ans < k:
        return True
    else:
        return False

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