結果

問題 No.817 Coin donation
ユーザー Yukino DX.Yukino DX.
提出日時 2023-11-17 18:58:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 557 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 64,864 KB
最終ジャッジ日時 2023-11-17 18:58:50
合計ジャッジ時間 4,587 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,112 KB
testcase_01 AC 28 ms
10,112 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 42 ms
11,520 KB
testcase_06 AC 102 ms
17,104 KB
testcase_07 AC 123 ms
18,744 KB
testcase_08 AC 478 ms
45,764 KB
testcase_09 AC 140 ms
20,168 KB
testcase_10 AC 729 ms
64,864 KB
testcase_11 AC 682 ms
64,864 KB
testcase_12 AC 757 ms
64,864 KB
testcase_13 AC 29 ms
10,112 KB
testcase_14 AC 28 ms
10,112 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict as dd

n, k = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]

cnts = dd(int)
for a, b in ab:
    cnts[a] += 1
    cnts[b + 1] -= 1

cnt = 0
acc = 0
cnts = [(key, val) for key, val in sorted(cnts.items())]
m = len(cnts)
for i in range(m - 1):
    acc += cnts[i][1]
    if cnt + acc * (cnts[i + 1][0] - cnts[i][0]) > k:
        ans = cnts[i][0] + (k - cnt) // acc
        if i == 0:
            ans -= 1
        print(ans)
        exit()

    cnt += acc * (cnts[i + 1][0] - cnts[i][0])
0