結果

問題 No.1071 ベホマラー
ユーザー ngtkanangtkana
提出日時 2020-06-05 21:39:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,427 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 204,064 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 14:42:57
合計ジャッジ時間 3,280 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
auto cmn = [](auto& x, auto y){ if (x>y) { x=y; return true; } return false; };
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i64 n, k, x, y;
    std::cin >> n >> k >> x >> y;

    vec<i64> a(n);
    for (i64 i=0; i<n; i++) {
        i64 p;
        std::cin >> p;
        p--;
        p = (p + k - 1) / k;
        a.at(i) = p;
    }
    std::sort(ALL(a), std::greater<>{});

    i64 z = std::min(n, y / x);
    i64 base = z < n ? a.at(z) : i64{0};

    i64 ans = base * y;
    for (i64 i=0; i<z; i++) {
        assert(base <= a.at(i));
        ans += (a.at(i) - base) * x;
    }
    std::cout << ans << '\n';
}
0