結果
問題 |
No.1071 ベホマラー
|
ユーザー |
|
提出日時 | 2020-06-05 23:12:56 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 939 bytes |
コンパイル時間 | 2,223 ms |
コンパイル使用メモリ | 163,912 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 18:25:06 |
合計ジャッジ時間 | 3,904 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 5 WA * 15 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main() { long long n,k,x,y; cin >> n >> k >> x >> y; int sum = 0; vector<long long>ans; for(int i=0; i<n; i++) { int x; cin>>x; x--; int a = x/k; if(x%k)a++; ans.push_back(a); //cout<<a<<" "; sum+=a; } //cout<<endl; sort(ans.begin(),ans.end()); if(sum*x<=y)cout<<sum*x<<endl; else { //cout<<ans[ans.size()-1]*y<<endl; long long res = sum*x; res = min(res, ans[ans.size()-1]*y); long long picked = 0; for(int i=0; i<n; i++) { picked += ans[i]; long long baki = sum - picked; long long next = baki - (n-(i+1))*ans[i]; //cout<<ans[i]<<" "<<baki<<" "<<next<<endl; //cout<<y*ans[i]<<" "<<x*next<<endl; res = min(res,y*ans[i]+x*next); } cout<<res<<endl; } }