結果

問題 No.1071 ベホマラー
ユーザー kyo1
提出日時 2021-01-18 00:10:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 590 bytes
コンパイル時間 2,211 ms
コンパイル使用メモリ 197,416 KB
最終ジャッジ日時 2025-01-18 02:00:16
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 19 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  vector<int64_t> A(N);
  for (auto &&e : A) {
    cin >> e;
    e = (e + K - 2) / K;
  }
  int x = (Y + X - 1) / X;
  sort(A.begin(), A.end());
  if (N - x <= 0) {
    int64_t res = 0;
    for (const auto &e : A) {
      res += e * X;
    }
    cout << res << '\n';
  } else {
    int64_t res = A[N - x] * Y;
    for (int i = N - x; i < N; i++) {
      res += (A[i] - A[N - x]) * X;
    }
    cout << res << '\n';
  }
  return 0;
}
0