結果
問題 |
No.1071 ベホマラー
|
ユーザー |
|
提出日時 | 2022-03-27 23:47:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,450 ms / 2,000 ms |
コード長 | 436 bytes |
コンパイル時間 | 285 ms |
コンパイル使用メモリ | 82,280 KB |
実行使用メモリ | 91,088 KB |
最終ジャッジ日時 | 2024-11-06 16:53:41 |
合計ジャッジ時間 | 13,799 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
n,k,x,y = map(int,input().split()) A = list(map(int,input().split())) l = 0 r = 10**20 def calc(m): count = 0 for a in A: if a-1 <= m*k: continue count += (a-1-m*k+(k-1))//k*x return count + y*m while r > l+2: c1 = (l*2+r)//3 c2 = (l+r*2)//3 if calc(c1) <= calc(c2): r = c2 else: l = c1 ans = 10**20 for i in range(l,r+2): ans = min(ans,calc(i)) print(ans)