結果

問題 No.1071 ベホマラー
ユーザー bonKotsu
提出日時 2021-06-09 19:09:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 1,728 ms
コンパイル使用メモリ 172,604 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-28 16:21:45
合計ジャッジ時間 3,303 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>

int main() {
  int n;
  int k, x, y;
  cin >> n >> k >> x >> y;

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




}
0