結果

問題 No.1071 ベホマラー
ユーザー kappybarkappybar
提出日時 2020-06-05 23:03:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,175 bytes
コンパイル時間 1,603 ms
コンパイル使用メモリ 172,964 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-09 22:55:19
合計ジャッジ時間 3,389 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 37 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
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 47 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 48 ms
5,376 KB
testcase_23 AC 48 ms
5,376 KB
testcase_24 AC 52 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    ll n;
    cin >> n ;
    ll k,x,y;
    cin >> k >> x >> y;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
        --a[i];
    }
    sort(a.begin(),a.end());
    rep(i,n) a[i] = (a[i]+k-1)/k;
    //rep(i,n) cout << a[i] << endl;
    vector<ll> cumsum(n,0);
    cumsum[n-1] = a[n-1];
    for(int i=n-2;i>=0;i--) cumsum[i] = cumsum[i+1] + a[i];
    //rep(i,n) cout << cumsum[i] << endl;
    /*
    if(y >= n*x){
        cout << cumsum[0] * x << endl;
        return 0;
    }
    */
    /*
    rep(i,n){
       cout << a[i] << " " ;
    }
    cout << endl;
    */

    ll ans = cumsum[0] * x;
    rep(i,n-1){
        ll res = a[i] * y;
        res += x * (cumsum[i+1] - (n-i-1)*a[i]);
        ans = min(ans,res);
        //cout << res << endl;
    }
    ll res = a[n-1] * y;
    ans = min(ans,res);
    cout << ans << endl;
    return 0;
}
0