結果
問題 |
No.1739 Princess vs. Dragoness (& AoE)
|
ユーザー |
|
提出日時 | 2021-10-28 23:47:30 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 947 bytes |
コンパイル時間 | 258 ms |
コンパイル使用メモリ | 82,428 KB |
実行使用メモリ | 115,028 KB |
最終ジャッジ日時 | 2024-11-25 11:05:57 |
合計ジャッジ時間 | 7,221 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.popleft() elif not q2: now = q1.pop() elif q1[-1] > q2[0]: now = q1.pop() else: now = q2.popleft() now = max(now - x, 0) q2.append(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))