結果

問題 No.1071 ベホマラー
ユーザー kcz146
提出日時 2020-06-18 22:53:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 654 bytes
コンパイル時間 4,324 ms
コンパイル使用メモリ 197,644 KB
最終ジャッジ日時 2025-01-11 05:16:17
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n, k, x, y;
    cin >> n >> k >> x >> y;
    vector<ll> a(n);
    for(auto &e: a) cin >> e, e = (e+k-1-1)/k;
    sort(a.begin(), a.end());

    ll r = 0, i = 0, t = 0;
    while(i < n) {
        if(x * (n - i) < y) {
            r += x * (a[i] - t);
        } else {
            r += y * (a[i] - t);
            t = a[i];
        }
        i++;
    }
    cout << r << endl;
}
0