結果

問題 No.1071 ベホマラー
ユーザー chocono2230chocono2230
提出日時 2020-06-05 22:16:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,159 bytes
コンパイル時間 1,759 ms
コンパイル使用メモリ 176,276 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-05-09 21:48:38
合計ジャッジ時間 14,433 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 805 ms
6,944 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1,149 ms
8,320 KB
testcase_18 AC 1,137 ms
8,320 KB
testcase_19 AC 1,128 ms
8,320 KB
testcase_20 AC 47 ms
6,944 KB
testcase_21 WA -
testcase_22 AC 47 ms
6,940 KB
testcase_23 AC 47 ms
6,940 KB
testcase_24 AC 1,118 ms
8,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  vector<int> a(n);
  map<int, int> c;
  ll csum = 0;
  rep(i, n){
    int in;
    cin >> in;
    in--;
    a.at(i) = in;
    c[(in+k-1)/k]++;
    csum += (ll)(in+k-1)/k;
  }
  ll ans = 1e18+5e17;
  ll ux = 0, xc = 0;
  rrepit(ritr, c){
    ll add = (ll)ritr->first * y;
    add += (ll)ux * x;
    ans = min(ans, add);
    cerr << ritr->first << " " << ritr->second << " " << ux << " " << add << endl;
    if(ritr != c.rend()){
      auto itr = ritr;
      itr++;
      ll diff = ritr->first - itr->first;
      ux += diff*(ritr->second);
      ux += diff*xc;
      xc += ritr->second;
    }
  }
  ll add = (ll)x * csum;
  ans = min(ans, add);
  cout << ans << endl;

  return 0;
}
0