結果
| 問題 |
No.817 Coin donation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-17 20:34:18 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 991 ms / 2,000 ms |
| コード長 | 531 bytes |
| コンパイル時間 | 91 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 65,496 KB |
| 最終ジャッジ日時 | 2024-09-26 05:32:32 |
| 合計ジャッジ時間 | 5,423 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 |
ソースコード
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 - 1) // acc - 1
print(ans)
exit()
cnt += acc * (cnts[i + 1][0] - cnts[i][0])