結果

問題 No.1071 ベホマラー
ユーザー k-ish0212k-ish0212
提出日時 2020-06-05 22:16:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 368 ms / 2,000 ms
コード長 908 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 10,988 KB
実行使用メモリ 40,564 KB
最終ジャッジ日時 2023-08-22 16:01:32
合計ジャッジ時間 6,536 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
29,704 KB
testcase_01 AC 133 ms
29,796 KB
testcase_02 AC 134 ms
29,600 KB
testcase_03 AC 134 ms
29,712 KB
testcase_04 AC 135 ms
29,672 KB
testcase_05 AC 135 ms
29,696 KB
testcase_06 AC 133 ms
29,756 KB
testcase_07 AC 133 ms
29,600 KB
testcase_08 AC 132 ms
29,632 KB
testcase_09 AC 132 ms
29,548 KB
testcase_10 AC 190 ms
38,748 KB
testcase_11 AC 190 ms
38,376 KB
testcase_12 AC 171 ms
35,300 KB
testcase_13 AC 276 ms
37,280 KB
testcase_14 AC 200 ms
38,952 KB
testcase_15 AC 208 ms
40,564 KB
testcase_16 AC 204 ms
40,560 KB
testcase_17 AC 332 ms
40,344 KB
testcase_18 AC 368 ms
40,524 KB
testcase_19 AC 292 ms
40,500 KB
testcase_20 AC 214 ms
40,416 KB
testcase_21 AC 184 ms
40,408 KB
testcase_22 AC 220 ms
40,232 KB
testcase_23 AC 241 ms
40,412 KB
testcase_24 AC 236 ms
40,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import math
n,k,x,y = map(int , input().split())
a = list(map(int, input().split()))
a.sort()
a = np.array(a)
ans = 0
count = 0
val = y//x
# print(val)
a-=1
while True:
    if max(a) > 0:
        if val > n:
            for i in a:
                ans += math.ceil(i/k)
                # print(i)
                # print(a)
            print(ans)
            exit()
        while val >= 0:
            while a[-val-1] > 1:
                # a -= k
                tmp = math.ceil(a[-val-1]/k)
                a -= k * tmp
                ans += y * tmp
                # print('a')
                # print(a)
            while a[-val] > 1:
                tmp = math.ceil(a[-val]/k)
                a[-val] -= k * tmp
                ans += x * tmp
                # print('b')
                # print(a)
            val -= 1
        # print(a)

    else:
        print(ans)
        exit()
0