結果

問題 No.3459 Defeat Slimes
コンテスト
ユーザー flippergo
提出日時 2026-06-15 09:55:03
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 956 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 90 ms
コンパイル使用メモリ 64,544 KB
実行使用メモリ 105,636 KB
最終ジャッジ日時 2026-10-22 12:32:36
合計ジャッジ時間 24,050 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)
0