結果

問題 No.1071 ベホマラー
ユーザー iqueue02iqueue02
提出日時 2020-07-13 22:42:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 2,395 ms
コンパイル使用メモリ 203,072 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 02:20:20
合計ジャッジ時間 4,729 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 42 ms
6,940 KB
testcase_11 AC 42 ms
6,944 KB
testcase_12 AC 28 ms
6,940 KB
testcase_13 AC 38 ms
6,944 KB
testcase_14 AC 45 ms
6,940 KB
testcase_15 AC 51 ms
6,940 KB
testcase_16 AC 51 ms
6,944 KB
testcase_17 AC 52 ms
6,944 KB
testcase_18 AC 53 ms
6,944 KB
testcase_19 AC 52 ms
6,940 KB
testcase_20 AC 49 ms
6,940 KB
testcase_21 AC 48 ms
6,940 KB
testcase_22 AC 49 ms
6,944 KB
testcase_23 AC 50 ms
6,944 KB
testcase_24 AC 51 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  int n;
  ll k, x, y;
  cin >> n >> k >> x >> y;
  vector<ll> a(n);
  rep(i,n) cin >> a[i], a[i]--;
  ll lim = 0;
  a.emplace_back(0);
  for (int i = 1; i <= n; i++) {
    if (x * i < y) lim = i;
  }
  sort(a.begin(), a.end(), greater<ll>());

  ll cnt = (a[lim] + k - 1) / k;
  ll res = cnt * y;
 
  for (int i = 0; i < lim; i++) {
    a[i] -= cnt * k;
    a[i] = max(0LL, a[i]);
    res += x * ((a[i] + k - 1) / k);
  }
  cout << res << endl;
  return 0;
}
0