結果

問題 No.1071 ベホマラー
ユーザー MineMine
提出日時 2020-09-01 13:45:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,692 KB
最終ジャッジ日時 2024-04-29 15:36:24
合計ジャッジ時間 4,454 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 27 ms
10,624 KB
testcase_02 AC 27 ms
10,752 KB
testcase_03 AC 28 ms
10,752 KB
testcase_04 AC 26 ms
10,752 KB
testcase_05 AC 26 ms
10,752 KB
testcase_06 AC 28 ms
10,624 KB
testcase_07 AC 27 ms
10,624 KB
testcase_08 AC 27 ms
10,624 KB
testcase_09 AC 32 ms
10,752 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k, x, y = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    if a[i] == 1:
        a[i] = 0
    else:
        a[i] = (a[i]-2)//k + 1

a.sort()
s = sum(a)
before = 0
ans = 0

for i in range(n):
    if (s-(n-i)*(a[i] - before))*x > y*(a[i] - before):
        ans += y*(a[i] - before)
        s -= (n-i)*(a[i] - before)
        before = a[i]
    else:
        MIN = 10**10
        for g in range(a[i]-before+1):
            if MIN > (s-(n-i)*g)*x+g*y:
                MIN = (s-(n-i)*g)*x+g*y
            else:
                break
        ans += MIN
        break

print(ans)
0