結果
| 問題 | No.1071 ベホマラー |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-05 21:35:16 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 612 bytes |
| 記録 | |
| コンパイル時間 | 1,368 ms |
| コンパイル使用メモリ | 215,836 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-10 12:48:33 |
| 合計ジャッジ時間 | 2,795 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
const long long INF=1LL<<61;
int main(){
int n;
lint k,x,y; scanf("%d%lld%lld%lld",&n,&k,&x,&y);
vector<lint> a(n);
rep(i,n) scanf("%lld",&a[i]);
rep(i,n) a[i]=(a[i]-1+k-1)/k;
sort(a.begin(),a.end());
vector<lint> cum(n+1);
rep(i,n) cum[i+1]=cum[i]+a[i];
lint ans=INF;
if(cum[n]<=ans/x) ans=cum[n]*x;
rep(i,n){
lint cost1=a[i]*y;
lint cost2=(cum[n]-cum[i+1]-(n-i-1)*a[i]);
if(cost2>=INF/x) continue;
cost2*=x;
ans=min(ans,cost1+cost2);
}
printf("%lld\n",ans);
return 0;
}