結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー lloyzlloyz
提出日時 2021-11-12 22:47:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,473 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 156,924 KB
最終ジャッジ日時 2024-05-04 10:20:27
合計ジャッジ時間 32,872 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,480 KB
testcase_01 AC 34 ms
52,608 KB
testcase_02 AC 32 ms
52,736 KB
testcase_03 WA -
testcase_04 AC 2,551 ms
156,924 KB
testcase_05 AC 223 ms
106,568 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 98 ms
93,184 KB
testcase_09 AC 143 ms
96,444 KB
testcase_10 AC 770 ms
92,444 KB
testcase_11 WA -
testcase_12 AC 46 ms
65,792 KB
testcase_13 WA -
testcase_14 AC 167 ms
97,708 KB
testcase_15 AC 2,631 ms
150,040 KB
testcase_16 AC 694 ms
87,760 KB
testcase_17 AC 1,237 ms
98,824 KB
testcase_18 AC 100 ms
92,032 KB
testcase_19 AC 667 ms
96,520 KB
testcase_20 WA -
testcase_21 AC 1,645 ms
126,684 KB
testcase_22 AC 2,299 ms
139,556 KB
testcase_23 AC 2,758 ms
154,524 KB
testcase_24 AC 401 ms
113,380 KB
testcase_25 AC 153 ms
100,808 KB
testcase_26 WA -
testcase_27 AC 159 ms
101,032 KB
testcase_28 WA -
testcase_29 AC 230 ms
106,460 KB
testcase_30 AC 2,639 ms
149,776 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 42 ms
60,800 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 54 ms
64,768 KB
testcase_39 AC 64 ms
68,352 KB
testcase_40 AC 48 ms
62,464 KB
testcase_41 AC 62 ms
66,560 KB
testcase_42 AC 49 ms
64,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, a, b, x, y = map(int, input().split())
H = list(map(int, input().split()))

left = 0
right = 10**9 + 1
while right - left > 1:
    mid = (left + right) // 2
    ca, cb = a, b
    Hc = H[:]
    for i in range(n):
        if Hc[i] < mid:
            Hc[i] = 0
        else:
            Hc[i] -= mid
    for i in range(n):
        q, r = divmod(Hc[i], x)
        if ca >= q:
            Hc[i] = r
            ca -= q
        else:
            Hc[i] -= ca * x
            ca = 0
        if ca == 0:
            break

    if ca > 0:
        Hcc = [(Hc[i], i) for i in range(n)]
        Hcc.sort(key=lambda x: x[0], reverse=True)
        for i in range(n):
            ind = Hcc[i][1]
            if Hc[ind] > 0:
                ca -= 1
                Hc[ind] = 0
            if ca == 0:
                break

    if cb > 0:
        cy = y
        for i in range(n):
            if Hc[i] > cy:
                Hc[i] -= cy
                cb -= 1
                if cb == 0:
                    break
                q, r = divmod(Hc[i], y)
                cb -= q
                if cb <= 0:
                    break
                Hc[i] = 0
                cy = y - r
            else:
                cy -= Hc[i]
                Hc[i] = 0
                if cy == 0:
                    cb -= 1
                    cy = y
                    if cb == 0:
                        break

    if sum(Hc) == 0:
        right = mid
    else:
        left = mid
print(right)

0