結果
| 問題 | No.3459 Defeat Slimes |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-26 11:32:01 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 592 ms / 3,000 ms |
| コード長 | 1,462 bytes |
| 記録 | |
| コンパイル時間 | 400 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 136,272 KB |
| 最終ジャッジ日時 | 2026-03-26 11:32:25 |
| 合計ジャッジ時間 | 21,242 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
import math
import sys
import heapq
from typing import List, Tuple
int1 = lambda x: int(x) - 1
input = lambda: sys.stdin.readline().rstrip('\n')
ii = lambda: int(input())
vi = lambda: list(map(int, input().split()))
vi1 = lambda: list(map(int1, input().split()))
def dbg(*args, **kwargs):
print(*(repr(arg) for arg in args), *(f'{k}: {repr(v)}' for k, v in kwargs.items()),
sep='; ', file=sys.stderr, flush=True)
def solve(x):
z = 10 ** len(x)
return z // math.gcd(z, int(x))
def main():
n, y, z = vi()
clx = []
for _ in range(n):
clx.append(tuple(vi()))
clx.sort(key=lambda x: x[1], reverse=True)
q = []
while clx and clx[-1][1] <= y:
c, _, x = clx.pop()
heapq.heappush(q, (-x, c))
ans = 0
while y < z and q:
# print(y, z, q)
mx, c = heapq.heappop(q)
x = -mx
nl = z
if clx:
nl = min(nl, clx[-1][1])
tu = -(-(nl - y) // x)
zz = min(tu, c)
ans += zz
c -= zz
y += zz * x
if c != 0:
heapq.heappush(q, (-x, c))
while clx and clx[-1][1] <= y:
c, _, x = clx.pop()
heapq.heappush(q, (-x, c))
if y >= z:
return ans
else:
return -1
def _start():
if (ret := main()) is not None:
print(*ret) if isinstance(ret, List) or isinstance(ret, Tuple) else print(ret)
if __name__ == '__main__':
_start()