結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー googol_S0googol_S0
提出日時 2021-11-12 21:41:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,695 ms / 3,000 ms
コード長 421 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 144,004 KB
最終ジャッジ日時 2024-11-25 17:40:35
合計ジャッジ時間 48,975 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

N,A,B,X,Y=map(int,input().split())
H=list(map(int,input().split()))
L,R=0,10**9
from heapq import *
def f(m):
  Q=[]
  heapify(Q)
  for i in range(N):
    heappush(Q,-max(0,H[i]-m))
  for i in range(A):
    x=heappop(Q)
    x=-x
    heappush(Q,-max(0,x-X))
  s=0
  while len(Q):
    s-=heappop(Q)
  if s<=B*Y:
    return 1
  else:
    return 0

while L<R:
  M=(L+R)>>1
  if f(M):
    R=M
  else:
    L=max(L+1,M)
print(L)
0