結果
| 問題 | No.3459 Defeat Slimes |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-28 16:01:44 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 999 bytes |
| 記録 | |
| コンパイル時間 | 285 ms |
| コンパイル使用メモリ | 77,812 KB |
| 実行使用メモリ | 122,528 KB |
| 最終ジャッジ日時 | 2026-02-28 16:02:17 |
| 合計ジャッジ時間 | 18,434 ms |
|
ジャッジサーバーID (参考情報) |
judge7 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 1 -- * 19 |
ソースコード
import heapq
def solve():
n,y,z = map(int, input().split())
avail = [] # (x, c)
toohigh = [] # (l, x, c)
for _ in range(n):
c,l,x = map(int, input().split())
if l <= y:
avail.append((-x, c))
else:
toohigh.append((l, x, c))
heapq.heapify(avail)
heapq.heapify(toohigh)
count = 0
if not avail:
print(-1)
return
x,c = heapq.heappop(avail)
x = -x
while z > y:
count += 1
y += x
c -= 1
if c==0 or (toohigh and toohigh[0][0] <= y):
if c!=0:
heapq.heappush(avail, (-x, c))
while toohigh and toohigh[0][0] <= y:
l,x,c = heapq.heappop(toohigh)
heapq.heappush(avail, (-x, c))
if not avail:
break
x,c = heapq.heappop(avail)
x = -x
if y >= z:
print(count)
else:
print(-1)
if __name__ == "__main__":
solve()