結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー mkawa2mkawa2
提出日時 2021-11-12 21:49:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,754 ms / 3,000 ms
コード長 1,149 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 139,812 KB
最終ジャッジ日時 2023-08-17 00:56:52
合計ジャッジ時間 27,572 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
71,464 KB
testcase_01 AC 83 ms
71,096 KB
testcase_02 AC 84 ms
71,472 KB
testcase_03 AC 87 ms
71,380 KB
testcase_04 AC 1,489 ms
115,676 KB
testcase_05 AC 812 ms
126,272 KB
testcase_06 AC 650 ms
121,364 KB
testcase_07 AC 85 ms
71,344 KB
testcase_08 AC 305 ms
97,908 KB
testcase_09 AC 360 ms
103,600 KB
testcase_10 AC 694 ms
87,392 KB
testcase_11 AC 627 ms
89,612 KB
testcase_12 AC 112 ms
77,072 KB
testcase_13 AC 1,039 ms
111,868 KB
testcase_14 AC 581 ms
108,448 KB
testcase_15 AC 1,050 ms
118,252 KB
testcase_16 AC 584 ms
86,748 KB
testcase_17 AC 654 ms
98,720 KB
testcase_18 AC 353 ms
90,348 KB
testcase_19 AC 271 ms
82,948 KB
testcase_20 AC 225 ms
82,940 KB
testcase_21 AC 539 ms
95,708 KB
testcase_22 AC 1,040 ms
114,440 KB
testcase_23 AC 1,692 ms
135,492 KB
testcase_24 AC 1,307 ms
126,628 KB
testcase_25 AC 492 ms
115,668 KB
testcase_26 AC 1,698 ms
139,812 KB
testcase_27 AC 580 ms
118,368 KB
testcase_28 AC 1,734 ms
137,116 KB
testcase_29 AC 720 ms
119,636 KB
testcase_30 AC 1,657 ms
129,220 KB
testcase_31 AC 1,754 ms
135,632 KB
testcase_32 AC 708 ms
123,572 KB
testcase_33 AC 105 ms
76,532 KB
testcase_34 AC 83 ms
71,404 KB
testcase_35 AC 123 ms
76,992 KB
testcase_36 AC 113 ms
76,800 KB
testcase_37 AC 96 ms
75,796 KB
testcase_38 AC 126 ms
77,060 KB
testcase_39 AC 111 ms
76,936 KB
testcase_40 AC 106 ms
76,288 KB
testcase_41 AC 124 ms
77,000 KB
testcase_42 AC 122 ms
77,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = 18446744073709551615
inf = 4294967295
md = 10**9+7
# md = 998244353

from heapq import *

n, a, b, x, y = LI()
hh = LI()

def ok(a):
    hp = []
    for h in hh:
        if h-m > 0: heappush(hp, -h+m)

    while a and hp:
        h = -heappop(hp)
        if h < x:
            a -= 1
        else:
            cur = min(a, h//x)
            h -= x*cur
            a -= cur
            if h > 0: heappush(hp, -h)

    s = -sum(hp)
    # print(s,hp)

    return s <= y*b

l, r = -1, 10**9+1
while l+1 < r:
    m = (l+r)//2
    if ok(a): r = m
    else: l = m

print(r)
0