結果
問題 | No.1739 Princess vs. Dragoness (& AoE) |
ユーザー | kaeru82433413 |
提出日時 | 2021-11-12 21:48:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,076 ms / 3,000 ms |
コード長 | 512 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 82,452 KB |
実行使用メモリ | 107,760 KB |
最終ジャッジ日時 | 2024-11-25 17:59:46 |
合計ジャッジ時間 | 37,288 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
from heapq import heappop as pop, heappush as push, heapify N, A, B, X, Y = map(int, input().split()) H = list(map(int, input().split())) def solve(k): hh = list(map(lambda x: -(x-k), H)) heapify(hh) for _ in range(A): h = -pop(hh) h -= X push(hh, -h) remain = 0 for h in hh: remain += max(0, -h) return remain <= Y*B ok, ng = max(H), -1 while abs(ok-ng) > 1: mid = (ok+ng)//2 if solve(mid): ok = mid else: ng = mid print(ok)