結果

問題 No.1071 ベホマラー
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-06-05 21:49:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 851 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 163,156 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-09 20:47:50
合計ジャッジ時間 3,012 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.05 21:46:51
**/

#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];
    }
    ll p = (y + x - 1) / x;
    ll ans = 0;
    sort(a.begin(), a.end());
    if (p <= 1) {
        cout << (a[n - 1] - 1 + k - 1) / k * y << endl;
        return 0;
    }
    if (p > n) {
        for (int i = 0; i < n; i++) {
            ans += (a[i] - 1 + k - 1) / k * x;
        }
        cout << ans << endl;
        return 0;
    }
    ll q = (a[n - p] - 1 + k - 1) / k;
    ans = (a[n - p] - 1 + k - 1) / k * y;
    for (int i = p; i < n; i++) {
        ans += (a[i] - 1 - q * k + k - 1) / k * x;
    }
    cout << ans << endl;
    return 0;
}
0