結果
問題 | No.1739 Princess vs. Dragoness (& AoE) |
ユーザー |
|
提出日時 | 2021-10-28 23:23:53 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 944 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 82,228 KB |
実行使用メモリ | 114,984 KB |
最終ジャッジ日時 | 2024-11-25 11:04:23 |
合計ジャッジ時間 | 8,520 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 14 WA * 26 |
ソースコード
n, a, b, x, y = map(int,input().split()) h = list(map(int,input().split())) def solve(n, a, b, x, y, h): h.sort() from collections import deque def check(k): q1 = deque() q2 = deque() for i in range(n): q1.appendleft(max(h[i] - k, 0)) for _ in range(a): now = 0 if not q1: now = q2.pop() elif not q2: now = q1.pop() elif q1[-1] > q2[-1]: now = q1.pop() else: now = q2.pop() now = max(now - x, 0) q2.appendleft(now) if sum(q1) + sum(q2) <= b * y: return True else: return False ok = 10 ** 9 ng = -1 while abs(ok - ng) > 1: mid = (ok + ng) // 2 if check(mid): ok = mid else: ng = mid return ok print(solve(n, a, b, x, y, h))