結果

問題 No.1071 ベホマラー
ユーザー kcvlexkcvlex
提出日時 2020-06-05 21:49:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 538 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,416 KB
実行使用メモリ 87,504 KB
最終ジャッジ日時 2023-08-22 15:03:39
合計ジャッジ時間 6,738 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,324 KB
testcase_01 AC 72 ms
71,376 KB
testcase_02 AC 74 ms
71,236 KB
testcase_03 AC 73 ms
71,308 KB
testcase_04 AC 77 ms
75,976 KB
testcase_05 AC 75 ms
75,216 KB
testcase_06 AC 76 ms
75,392 KB
testcase_07 AC 74 ms
75,452 KB
testcase_08 AC 75 ms
75,372 KB
testcase_09 AC 71 ms
71,428 KB
testcase_10 AC 138 ms
85,148 KB
testcase_11 AC 132 ms
84,808 KB
testcase_12 AC 120 ms
81,668 KB
testcase_13 AC 356 ms
83,796 KB
testcase_14 AC 157 ms
85,468 KB
testcase_15 AC 151 ms
86,988 KB
testcase_16 AC 146 ms
87,072 KB
testcase_17 AC 417 ms
87,116 KB
testcase_18 AC 413 ms
86,896 KB
testcase_19 AC 387 ms
87,072 KB
testcase_20 AC 538 ms
87,424 KB
testcase_21 AC 206 ms
87,408 KB
testcase_22 AC 537 ms
87,504 KB
testcase_23 AC 400 ms
87,428 KB
testcase_24 AC 245 ms
86,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def ceil_div(x, y):
    ret = x // y
    if x % y == 0: 
        return ret
    else:
        return ret + 1;

def calc(n, k, x, y, av, ycnt):
    ret = y * ycnt
    for e in av:
        rest = e - k * ycnt
        if rest <= 0:
            continue
        ret += x * ceil_div(rest, k)
    return ret


tmp = tuple(list(map(int, input().split(' '))))
a = list(map(int, input().split(' ')))
av = [ e - 1 for e in a ]
n, k, x, y = tmp
x0 = 0
x3 = int(1e18)
f = lambda arg: calc(n, k, x, y, av, arg)
while 2 < x3 - x0:
    x1 = (2 * x0 + x3) // 3
    x2 = (x0 + 2 * x3) // 3
    f1 = f(x1)
    f2 = f(x2)
    if f1 < f2:
        x3 = x2
    else:
        x0 = x1
print(min([f(x0), f(x0+1), f(x0+2)]))
0