結果

問題 No.1071 ベホマラー
ユーザー Rayhan AhmadRayhan Ahmad
提出日時 2020-06-05 23:12:56
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 939 bytes
コンパイル時間 2,384 ms
コンパイル使用メモリ 166,088 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-07 21:50:02
合計ジャッジ時間 3,703 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
    }
}
0