結果

問題 No.817 Coin donation
ユーザー Yukino DX.
提出日時 2023-11-17 18:58:45
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 557 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 65,640 KB
最終ジャッジ日時 2024-09-26 05:31:29
合計ジャッジ時間 4,385 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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