結果

問題 No.1071 ベホマラー
ユーザー brthyyjpbrthyyjp
提出日時 2020-06-05 21:46:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 442 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 93,064 KB
最終ジャッジ日時 2023-08-22 14:55:32
合計ジャッジ時間 3,823 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,532 KB
testcase_01 AC 71 ms
71,288 KB
testcase_02 AC 71 ms
71,300 KB
testcase_03 AC 71 ms
71,472 KB
testcase_04 AC 70 ms
71,432 KB
testcase_05 AC 70 ms
71,352 KB
testcase_06 AC 72 ms
71,524 KB
testcase_07 AC 69 ms
71,224 KB
testcase_08 AC 70 ms
71,544 KB
testcase_09 AC 70 ms
71,560 KB
testcase_10 AC 105 ms
90,340 KB
testcase_11 AC 105 ms
89,380 KB
testcase_12 AC 94 ms
84,240 KB
testcase_13 AC 104 ms
87,404 KB
testcase_14 AC 108 ms
90,880 KB
testcase_15 AC 115 ms
92,948 KB
testcase_16 AC 111 ms
92,640 KB
testcase_17 AC 114 ms
93,064 KB
testcase_18 AC 111 ms
92,724 KB
testcase_19 AC 113 ms
92,952 KB
testcase_20 AC 96 ms
92,484 KB
testcase_21 AC 96 ms
92,444 KB
testcase_22 AC 98 ms
92,544 KB
testcase_23 AC 98 ms
92,476 KB
testcase_24 AC 105 ms
92,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k, x, y = map(int, input().split())
A = list(map(int, input().split()))

B = [0]*n
for i, a in enumerate(A):
    if (a-1)%k == 0:
        B[i] = (a-1)//k
    else:
        B[i] = (a-1)//k+1
B.sort()
#print(B)

import math
k = math.ceil(y/x)

if k == 0:
    ans = B[-1]*y
    print(ans)
    exit()

if k > n:
    ans = sum(B)*x
    print(ans)
    exit()

ans = y*B[n-k]
for i in range(n-k, n):
    b = B[i]-B[n-k]
    ans += x*b
print(ans)
0