結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー qib
提出日時 2023-03-07 23:57:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,045 ms / 3,000 ms
コード長 466 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,532 KB
実行使用メモリ 136,380 KB
最終ジャッジ日時 2024-09-18 02:18:10
合計ジャッジ時間 34,833 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

n, a, b, x, y = map(int, input().split())
h = list(map(int, input().split()))

ok = 10 ** 9
ng = -1
while abs(ok - ng) > 1:
  mid = (ok + ng) // 2
  hp = []
  for i in range(n):
    if h[i] > mid:
      heapq.heappush(hp, - (h[i] - mid))

  rest = a
  while rest > 0 and len(hp) > 0:
    cur = heapq.heappop(hp)
    rest -= 1
    if - cur - x > 0:
      heapq.heappush(hp, cur + x)

  if - sum(hp) <= b * y:
    ok = mid
  else:
    ng = mid

print(ok)
0