結果

問題 No.3459 Defeat Slimes
コンテスト
ユーザー sakasama
提出日時 2026-02-28 15:50:48
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 779 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 336 ms
コンパイル使用メモリ 78,004 KB
実行使用メモリ 122,268 KB
最終ジャッジ日時 2026-02-28 15:51:13
合計ジャッジ時間 18,970 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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
    while z > y and avail:
        count += 1
        x,c = heapq.heappop(avail)
        x = -x
        y += x
        c -= 1
        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 y >= z:
        print(count)
    else:
        print(-1)


if __name__ == "__main__":
    solve()
0