結果

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

ソースコード

diff #
raw source code

from heapq import *
def main():
    n, y, z = list(map(int, input().split()))
    Q = [list(map(int, input().split())) for _ in range(n)] + [[-1, z, -1]]
    Q.sort(key = lambda x: -x[1])
    hq = []
    ans = 0
    while 1:
        while Q[-1][1] <= y:
            c, l, x = Q.pop()
            if c == -1:
                return ans
            heappush(hq, (-x, c))
        if hq:
             x, c = heappop(hq)
             x = -x
             nc = (Q[-1][1] - y + x - 1) // x
             mc = min(c, nc)
             c -= mc
             y += mc * x
             ans += mc
             if c:
                 heappush(hq, (-x, c))
        else:
            break
    return -1

print(main())
0