結果
| 問題 | No.3459 Defeat Slimes |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2026-06-11 03:38:10 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 631 ms / 3,000 ms |
| コード長 | 823 bytes |
| 記録 | |
| コンパイル時間 | 1,221 ms |
| コンパイル使用メモリ | 85,336 KB |
| 実行使用メモリ | 138,496 KB |
| 最終ジャッジ日時 | 2026-06-11 03:38:37 |
| 合計ジャッジ時間 | 23,718 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
N,Y,Z=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(N)]
Q=[]
R=[]
for c,l,x in A:
if l<=Y:
heappush(Q,(-x,c))
else:
R.append((l,x,c))
R.sort(reverse=True)
ANS=0
#print(Q)
while Q and Y<Z:
if R:
nec=R[-1][0]
else:
nec=Z
nec=min(nec,Z)
plus,ko=heappop(Q)
plus=-plus
if nec>Y:
need=(nec-Y+plus-1)//plus
else:
need=float("inf")
use=min(need,ko)
ko-=use
Y+=plus*use
ANS+=use
if ko>0:
heappush(Q,(-plus,ko))
while R:
if R[-1][0]<=Y:
l,x,c=R.pop()
heappush(Q,(-x,c))
else:
break
if Y>=Z:
print(ANS)
else:
print(-1)
titia