結果

問題 No.1071 ベホマラー
ユーザー 🍮かんプリン
提出日時 2020-06-05 22:12:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 812 bytes
コンパイル時間 1,356 ms
コンパイル使用メモリ 164,576 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-17 15:41:50
合計ジャッジ時間 3,101 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.05 22:12:32
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

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