結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,112 KB
testcase_01 AC 30 ms
10,112 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 43 ms
11,520 KB
testcase_06 AC 105 ms
17,096 KB
testcase_07 AC 124 ms
18,736 KB
testcase_08 AC 495 ms
45,756 KB
testcase_09 AC 138 ms
20,160 KB
testcase_10 AC 775 ms
64,856 KB
testcase_11 AC 718 ms
64,856 KB
testcase_12 AC 746 ms
64,852 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 29 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

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:
        id = (k - cnt) // acc
        print(cnts[i][0] + id)
        exit()

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