結果
問題 | No.1071 ベホマラー |
ユーザー |
|
提出日時 | 2022-09-01 19:33:28 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 258 ms / 2,000 ms |
コード長 | 581 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 82,064 KB |
実行使用メモリ | 85,284 KB |
最終ジャッジ日時 | 2024-11-14 10:41:30 |
合計ジャッジ時間 | 4,333 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
n,k,x,y = map(int,input().split()) a = [int(i)-1 for i in input().split()] low = 0 high = (k-1+max(a))//k def f(num): val = num*y for i in range(n): tmp = (max(0,a[i]-num*k)+k-1)//k val += tmp*x return val #print(low,high) #exit() cnt = 0 while low+1 < high: c1 = int((low*2+high)/3) c2 = int((low+high*2)/3) if f(c1) > f(c2): if low == c1: low += 1 else: low = c1 else: if high == c2: high -= 1 else: high = c2 ans = min(f(high),f(low)) print(ans)