結果
問題 | No.1071 ベホマラー |
ユーザー |
![]() |
提出日時 | 2020-07-13 22:42:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 664 bytes |
コンパイル時間 | 2,097 ms |
コンパイル使用メモリ | 198,256 KB |
最終ジャッジ日時 | 2025-01-11 20:20:24 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
#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;}