結果
問題 | No.1071 ベホマラー |
ユーザー | Ribura |
提出日時 | 2020-06-05 22:01:58 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 255 ms / 2,000 ms |
コード長 | 491 bytes |
コンパイル時間 | 94 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 20,100 KB |
最終ジャッジ日時 | 2024-12-17 14:55:31 |
合計ジャッジ時間 | 3,963 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, k, x, y = map(int, readline().split()) a = list(map(int, readline().split())) a.sort() ans = 0 now = 1 for i, aa in enumerate(a): if aa - now <= 0: continue m = (aa - now) // k ans += min(m * y, m * x * (n - i)) now += m * k if (aa - now) % k != 0: ans += min(x * (n - i), y) now += k print(ans)