結果
| 問題 |
No.1071 ベホマラー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-07 00:30:27 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 732 bytes |
| コンパイル時間 | 1,017 ms |
| コンパイル使用メモリ | 132,532 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 18:30:50 |
| 合計ジャッジ時間 | 2,642 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using int64 = long long;
int main() {
int64 n,k,x,y;
cin >> n >> k >> x >> y;
vector a(n,0LL);
for (int i=0; i<n; i++) {
cin >> a[i];
a[i]--;
}
sort(a.rbegin(), a.rend());
int64 ans = 0;
int64 cnt = 0;
while(!empty(a)) {
if (a.size()*x >= y) {
int64 e = (a.back()-cnt*k+k-1) / k;
ans += y * e;
cnt += e;
while(!empty(a) && a.back() - cnt*k <= 0)
a.pop_back();
} else {
int64 e = (a.back() - cnt*k +k-1) / k;
ans += x * e;
a.pop_back();
}
}
cout << ans << endl;
}