結果
| 問題 | No.3459 Defeat Slimes |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-06-15 09:55:03 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 802 ms / 3,000 ms |
| コード長 | 956 bytes |
| 記録 | |
| コンパイル時間 | 334 ms |
| コンパイル使用メモリ | 85,404 KB |
| 実行使用メモリ | 119,776 KB |
| 最終ジャッジ日時 | 2026-06-15 09:55:28 |
| 合計ジャッジ時間 | 24,224 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
import heapq
N,Y,Z = map(int,input().split())
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[1])
cur = Y
iLev = -1
heap = []
for i in range(N):
c,l,x = A[i]
if cur>=l:
heapq.heappush(heap,(-x,c))
iLev = i
if iLev<0:
print(-1)
else:
ans = 0
flag = -1
if iLev<N-1:
nc,nl,nx = A[iLev+1]
delta = min(nl-cur,Z-cur)
else:
delta = Z-cur
while heap:
x,c = heapq.heappop(heap)
x = -x
cnt = min((delta+x-1)//x,c)
c -= cnt
cur += x*cnt
ans += cnt
if cur>=Z:
flag = ans
break
if c>0:
heapq.heappush(heap,(-x,c))
iLev += 1
if iLev<N:
heapq.heappush(heap,(-A[iLev][2],A[iLev][0]))
if iLev<N-1:
nc,nl,nx = A[iLev+1]
delta = min(nl-cur,Z-cur)
else:
delta = Z-cur
print(flag)