結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー ShirotsumeShirotsume
提出日時 2021-10-28 23:23:53
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 944 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 111,340 KB
最終ジャッジ日時 2023-08-16 20:51:16
合計ジャッジ時間 12,427 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 100 ms
76,828 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 266 ms
100,588 KB
testcase_07 AC 100 ms
76,808 KB
testcase_08 AC 151 ms
83,652 KB
testcase_09 AC 178 ms
91,684 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 104 ms
77,688 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 135 ms
79,412 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 324 ms
104,940 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 323 ms
108,272 KB
testcase_32 AC 332 ms
111,340 KB
testcase_33 WA -
testcase_34 AC 99 ms
76,960 KB
testcase_35 AC 112 ms
77,012 KB
testcase_36 AC 106 ms
76,964 KB
testcase_37 AC 106 ms
76,920 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0