結果

問題 No.1739 Princess vs. Dragoness (& AoE)
ユーザー customfolkcustomfolk
提出日時 2021-11-12 22:01:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 668 ms / 3,000 ms
コード長 1,431 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 82,824 KB
実行使用メモリ 149,832 KB
最終ジャッジ日時 2024-05-04 08:42:14
合計ジャッジ時間 12,607 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
62,560 KB
testcase_01 AC 43 ms
63,672 KB
testcase_02 AC 47 ms
63,116 KB
testcase_03 AC 45 ms
62,436 KB
testcase_04 AC 643 ms
112,840 KB
testcase_05 AC 668 ms
130,984 KB
testcase_06 AC 79 ms
91,436 KB
testcase_07 AC 47 ms
61,668 KB
testcase_08 AC 395 ms
126,352 KB
testcase_09 AC 529 ms
137,628 KB
testcase_10 AC 270 ms
96,308 KB
testcase_11 AC 58 ms
74,528 KB
testcase_12 AC 70 ms
76,992 KB
testcase_13 AC 72 ms
83,828 KB
testcase_14 AC 506 ms
123,004 KB
testcase_15 AC 619 ms
110,348 KB
testcase_16 AC 228 ms
90,364 KB
testcase_17 AC 340 ms
100,252 KB
testcase_18 AC 315 ms
101,264 KB
testcase_19 AC 236 ms
98,576 KB
testcase_20 AC 62 ms
72,812 KB
testcase_21 AC 452 ms
103,024 KB
testcase_22 AC 560 ms
107,792 KB
testcase_23 AC 636 ms
108,568 KB
testcase_24 AC 661 ms
117,464 KB
testcase_25 AC 659 ms
149,832 KB
testcase_26 AC 88 ms
93,284 KB
testcase_27 AC 664 ms
142,516 KB
testcase_28 AC 91 ms
93,320 KB
testcase_29 AC 665 ms
136,504 KB
testcase_30 AC 634 ms
110,356 KB
testcase_31 AC 92 ms
93,724 KB
testcase_32 AC 87 ms
93,204 KB
testcase_33 AC 56 ms
69,496 KB
testcase_34 AC 43 ms
61,988 KB
testcase_35 AC 42 ms
63,068 KB
testcase_36 AC 42 ms
62,012 KB
testcase_37 AC 42 ms
61,804 KB
testcase_38 AC 57 ms
70,780 KB
testcase_39 AC 57 ms
71,392 KB
testcase_40 AC 55 ms
68,336 KB
testcase_41 AC 57 ms
70,220 KB
testcase_42 AC 55 ms
70,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque, Counter
from heapq import heapify, heappop, heappush
import math
from copy import deepcopy
from itertools import combinations, permutations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right

import sys

def input():
    return sys.stdin.readline().rstrip()
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getListGraph():
    return list(map(lambda x:int(x) - 1, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

mod = 10 ** 9 + 7
MOD = 998244353
sys.setrecursionlimit(10000000)
inf = float('inf')
eps = 10 ** (-15)
dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]

#############
# Main Code #
#############

"""
二分探索
"""

def f(x):
    h = [i - x if i - x >= 0 else 0 for i in H]
    a = A

    for i in range(N):
        t = min(h[i] // X, a)
        h[i] -= X * t
        a -= t

    h.sort()
    for i in range(N - 1, -1, -1):
        if a:
            h[i] -= X
            a -= 1
    h = [h_o if h_o >= 0 else 0 for h_o in h]

    if B * Y >= sum(h):
        return True
    else:
        return False

N, A, B, X, Y = getNM()
H = getList()
if f(0):
    print(0)
    exit()

ng, ok = -1, 10 ** 18
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if f(mid):
        ok = mid
    else:
        ng = mid
print(ok)
0