結果

問題 No.1071 ベホマラー
ユーザー kcvlexkcvlex
提出日時 2020-06-05 21:49:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 489 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 82,028 KB
実行使用メモリ 86,416 KB
最終ジャッジ日時 2024-05-09 20:47:34
合計ジャッジ時間 5,268 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,552 KB
testcase_01 AC 37 ms
52,852 KB
testcase_02 AC 38 ms
52,340 KB
testcase_03 AC 37 ms
52,460 KB
testcase_04 AC 40 ms
58,160 KB
testcase_05 AC 40 ms
58,620 KB
testcase_06 AC 41 ms
58,572 KB
testcase_07 AC 39 ms
58,136 KB
testcase_08 AC 40 ms
59,052 KB
testcase_09 AC 36 ms
53,072 KB
testcase_10 AC 105 ms
84,244 KB
testcase_11 AC 97 ms
81,848 KB
testcase_12 AC 82 ms
78,280 KB
testcase_13 AC 311 ms
82,600 KB
testcase_14 AC 122 ms
84,636 KB
testcase_15 AC 119 ms
86,068 KB
testcase_16 AC 115 ms
85,860 KB
testcase_17 AC 378 ms
85,908 KB
testcase_18 AC 371 ms
85,984 KB
testcase_19 AC 345 ms
85,716 KB
testcase_20 AC 489 ms
86,084 KB
testcase_21 AC 171 ms
86,416 KB
testcase_22 AC 485 ms
86,352 KB
testcase_23 AC 357 ms
85,824 KB
testcase_24 AC 202 ms
85,832 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