結果
問題 | No.1739 Princess vs. Dragoness (& AoE) |
ユーザー |
![]() |
提出日時 | 2021-11-12 21:46:46 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 596 bytes |
コンパイル時間 | 161 ms |
コンパイル使用メモリ | 82,664 KB |
実行使用メモリ | 145,200 KB |
最終ジャッジ日時 | 2024-11-25 17:55:13 |
合計ジャッジ時間 | 42,422 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 TLE * 1 |
ソースコード
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): a=0 b=0 for i in range(N): a+=max(H[i]-m,0) b+=(max(H[i]-m,0)+X-1)//X if b<=A or a<=B*Y: return 1 if b>A*X+B*Y: return 0 Q=[] heapify(Q) for i in range(N): heappush(Q,-max(0,H[i]-m)) for i in range(A): x=heappop(Q) if x==0: return 1 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)