結果
| 問題 | No.3459 Defeat Slimes |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-28 20:47:09 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,007 ms / 3,000 ms |
| コード長 | 1,415 bytes |
| 記録 | |
| コンパイル時間 | 535 ms |
| コンパイル使用メモリ | 78,296 KB |
| 実行使用メモリ | 163,784 KB |
| 最終ジャッジ日時 | 2026-02-28 20:47:36 |
| 合計ジャッジ時間 | 24,369 ms |
|
ジャッジサーバーID (参考情報) |
judge7 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
## https://yukicoder.me/problems/no/3459
import heapq
def main():
N, Y, Z = map(int, input().split())
clx = []
for _ in range(N):
c, l, x = map(int, input().split())
clx.append((c, l, x))
queue = []
level_map = {Z:[]}
for i in range(N):
c, l, x = clx[i]
if Y < l < Z:
if l not in level_map:
level_map[l] = []
level_map[l].append((c, x))
elif l <= Y:
heapq.heappush(queue, (-x, c))
level_array = [(l, slime_array) for l, slime_array in level_map.items()]
level_array.sort(key=lambda x: x[0])
answer = 0
for border_level, slime_array in level_array:
while len(queue) > 0:
_x, c = heapq.heappop(queue)
x = -_x
y = border_level - Y
need_c = y // x
need_c += 1 if y % x > 0 else 0
c0 = min(c, need_c)
c -= c0
answer += c0
if c > 0:
heapq.heappush(queue,(-x, c))
Y += c0 * x
if Y >= border_level:
break
if Y >= border_level:
for c, x in slime_array:
heapq.heappush(queue, (-x, c))
else:
print(-1)
return
print(answer)
if __name__ == "__main__":
main()