結果
| 問題 | No.1071 ベホマラー | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-06-26 10:39:18 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 83 ms / 2,000 ms | 
| コード長 | 517 bytes | 
| コンパイル時間 | 170 ms | 
| コンパイル使用メモリ | 82,036 KB | 
| 実行使用メモリ | 86,524 KB | 
| 最終ジャッジ日時 | 2024-07-03 22:10:47 | 
| 合計ジャッジ時間 | 3,036 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 20 | 
ソースコード
import sys
sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline
def solve():
    N, K, X, Y = map(int, rl().split())
    A = [ai - 1 for ai in map(int, rl().split())]
    
    lim = Y // X
    if lim == 0:
        print(-(-max(A) // K))
        return
    
    B = [-(-ai // K) for ai in A]
    B.sort()
    C = B[-lim:]
    
    cnt = 0
    if len(C) != N:
        cnt = B[-(lim + 1)]
    
    ans = cnt * Y
    for ci in C:
        ans += (ci - cnt) * X
    print(ans)
if __name__ == '__main__':
    solve()
            
            
            
        