結果
| 問題 |
No.1071 ベホマラー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-05 23:44:44 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,179 bytes |
| コンパイル時間 | 2,336 ms |
| コンパイル使用メモリ | 165,144 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 18:27:34 |
| 合計ジャッジ時間 | 3,878 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 12 WA * 8 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define ll double
const long long MAX = 4611686016279904256LL;
bool check(ll ans)
{
//cout<<ans<<endl;
if(ans < MAX)return true;
else return false;
}
int main()
{
int n,k;
ll x,y;
cin >> n >> k >> x >> y;
ll sum = 0;
vector<ll>ans;
for(int i=0; i<n; i++)
{
int x;
cin>>x;
x--;
ll a = x/k;
if(x%k)a++;
ans.push_back(a);
//cout<<a<<" ";
sum+=a;
}
//cout<<endl;
sort(ans.begin(),ans.end());
//cout<<ans[ans.size()-1]*y<<endl;
ll res = sum*x;
res = min(res, ans[ans.size()-1]*y);
ll picked = 0;
for(int i=0; i<n; i++)
{
picked += ans[i];
ll baki = sum - picked;
ll next = baki - (n-(i+1))*ans[i];
//cout<<ans[i]<<" "<<baki<<" "<<next<<endl;
//cout<<y*ans[i]<<" "<<x*next<<endl;
ll first = y * ans[i];
ll second = x * next;
//cout<< first << " " << second <<endl;
if(check(first + second))
{
//cout<<"YES\n";
res = min(res, first + second);
}
}
cout<< (long long)res <<endl;
}