結果

問題 No.1071 ベホマラー
ユーザー ka_zuka_zu
提出日時 2020-06-05 21:52:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 92,928 KB
最終ジャッジ日時 2024-05-09 20:54:12
合計ジャッジ時間 3,255 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,096 KB
testcase_01 AC 35 ms
52,096 KB
testcase_02 AC 34 ms
51,968 KB
testcase_03 AC 36 ms
52,352 KB
testcase_04 AC 34 ms
52,480 KB
testcase_05 AC 36 ms
52,224 KB
testcase_06 AC 36 ms
51,840 KB
testcase_07 AC 38 ms
51,712 KB
testcase_08 AC 36 ms
51,712 KB
testcase_09 AC 36 ms
52,508 KB
testcase_10 AC 79 ms
87,296 KB
testcase_11 AC 76 ms
85,632 KB
testcase_12 AC 65 ms
76,928 KB
testcase_13 AC 73 ms
83,072 KB
testcase_14 AC 80 ms
88,448 KB
testcase_15 AC 87 ms
91,648 KB
testcase_16 AC 83 ms
92,032 KB
testcase_17 AC 85 ms
92,800 KB
testcase_18 AC 86 ms
92,928 KB
testcase_19 AC 86 ms
92,672 KB
testcase_20 AC 71 ms
91,904 KB
testcase_21 AC 71 ms
91,392 KB
testcase_22 AC 71 ms
91,776 KB
testcase_23 AC 73 ms
92,672 KB
testcase_24 AC 79 ms
92,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

N, K, X, Y = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
C = []
for i in range(N):
    C.append(math.ceil((A[i]-1)/ K))

cnt = math.ceil(Y / X)#これ未満はベホイミのほうが良い
if cnt > N:
    print(sum(C) * X)
    exit()
else:
    B = C[-cnt]
    #print("A = ",A)
    #print("cnt = ", cnt)
    #print("B = ",B)
    #print("C = ",C)
    #print(C[-cnt:])
    ans = 0
    ans += B * Y
    tmp = sum(C[-cnt:]) - B *cnt
    ans += tmp * X
    print(ans)
0