結果

問題 No.1071 ベホマラー
ユーザー ttrttr
提出日時 2020-06-05 21:36:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,848 KB
最終ジャッジ日時 2024-05-09 20:19:24
合計ジャッジ時間 3,852 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 29 ms
10,880 KB
testcase_04 AC 29 ms
10,752 KB
testcase_05 AC 28 ms
10,752 KB
testcase_06 AC 26 ms
10,752 KB
testcase_07 AC 25 ms
10,880 KB
testcase_08 AC 26 ms
10,880 KB
testcase_09 AC 26 ms
10,880 KB
testcase_10 AC 185 ms
19,940 KB
testcase_11 AC 172 ms
19,528 KB
testcase_12 AC 123 ms
16,572 KB
testcase_13 AC 127 ms
18,504 KB
testcase_14 AC 198 ms
20,368 KB
testcase_15 AC 226 ms
21,848 KB
testcase_16 AC 226 ms
21,840 KB
testcase_17 AC 184 ms
21,844 KB
testcase_18 AC 170 ms
21,844 KB
testcase_19 AC 201 ms
21,840 KB
testcase_20 AC 140 ms
21,680 KB
testcase_21 AC 116 ms
21,684 KB
testcase_22 AC 146 ms
21,676 KB
testcase_23 AC 109 ms
21,676 KB
testcase_24 AC 200 ms
21,840 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