結果

問題 No.1071 ベホマラー
ユーザー Rayhan AhmadRayhan Ahmad
提出日時 2020-06-06 00:24:51
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,104 bytes
コンパイル時間 2,420 ms
コンパイル使用メモリ 164,672 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-07 21:53:36
合計ジャッジ時間 4,118 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 37 ms
5,376 KB
testcase_14 AC 45 ms
5,376 KB
testcase_15 AC 51 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 51 ms
5,376 KB
testcase_18 AC 51 ms
5,376 KB
testcase_19 AC 51 ms
5,376 KB
testcase_20 AC 48 ms
5,376 KB
testcase_21 AC 46 ms
5,376 KB
testcase_22 AC 48 ms
5,376 KB
testcase_23 AC 48 ms
5,376 KB
testcase_24 AC 50 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#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 << (ll)ans[ans.size()-1] * (ll) y << endl;
    ll picked = 0;
    for(int i=0; i<n; i++)
    {
        picked += ans[i];
        ll baki = (ll) sum - (ll) 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;
}
0