結果

問題 No.1071 ベホマラー
ユーザー ttrttr
提出日時 2020-06-05 21:36:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 18,972 KB
最終ジャッジ日時 2023-08-22 14:35:48
合計ジャッジ時間 3,634 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,164 KB
testcase_01 AC 16 ms
8,208 KB
testcase_02 AC 16 ms
8,164 KB
testcase_03 AC 15 ms
8,120 KB
testcase_04 AC 15 ms
8,184 KB
testcase_05 AC 16 ms
8,184 KB
testcase_06 AC 16 ms
8,084 KB
testcase_07 AC 19 ms
8,136 KB
testcase_08 AC 16 ms
8,100 KB
testcase_09 AC 16 ms
8,184 KB
testcase_10 AC 175 ms
17,192 KB
testcase_11 AC 169 ms
16,768 KB
testcase_12 AC 116 ms
13,772 KB
testcase_13 AC 114 ms
15,768 KB
testcase_14 AC 183 ms
17,376 KB
testcase_15 AC 207 ms
18,972 KB
testcase_16 AC 211 ms
18,868 KB
testcase_17 AC 154 ms
18,864 KB
testcase_18 AC 135 ms
18,868 KB
testcase_19 AC 173 ms
18,884 KB
testcase_20 AC 109 ms
18,776 KB
testcase_21 AC 86 ms
18,828 KB
testcase_22 AC 108 ms
18,796 KB
testcase_23 AC 86 ms
18,968 KB
testcase_24 AC 180 ms
18,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K,X,Y = map(int, input().split())
A = [int(a) for a in input().split()]

for i in range(N):
    if (A[i]-1)%K == 0:
        A[i] = (A[i]-1)//K
    else:
        A[i] = (A[i]-1)//K+1

A.sort()
ans = 0
import bisect
cnt = 0
idx = bisect.bisect_right(A, cnt)
while idx < N:
    if (N-idx)*X > Y:
        ans += Y*(A[idx]-cnt)
        cnt = A[idx]
        idx = bisect.bisect_right(A, cnt)
    else:
        for i in range(idx, N):
            ans += X*(A[i]-cnt)
        break

print(ans)
0