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