結果
| 問題 | No.1071 ベホマラー |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-05 22:48:39 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,185 bytes |
| 記録 | |
| コンパイル時間 | 803 ms |
| コンパイル使用メモリ | 104,328 KB |
| 実行使用メモリ | 16,200 KB |
| 最終ジャッジ日時 | 2026-05-26 20:40:48 |
| 合計ジャッジ時間 | 4,541 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 5 TLE * 1 -- * 14 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);cin.tie(0);
int n;
ll k, x, y;
cin >> n >> k >> x >> y;
vector<ll> a(n);
vector<ll> na(n,1);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
ll mp = 0;
int sortcnt = 0;
while (1) {
int en = 0;
for (int i = 0; i < a.size(); i++) {
if (a[i] <= na[i]) {
en++;
}
}
if (en >= a.size()) { break; }
int choi = 0;
int ykk = 0;
vector<ll> noa(n);
for (int i = 0; i < na.size(); i++) {
if (a[i] > na[i]) {
ykk++;
noa[i] = a[i] - na[i];
}
}
if (y < ykk * x)choi = 1;
if (choi == 1) {
sort(noa.begin(), noa.end());
if(noa[sortcnt] == 0)sortcnt++;
ll kk = (noa[sortcnt] / k);
if (kk == 0)kk++;
for (int i = 0; i < na.size(); i++) {
na[i] += k * kk;
}mp += y * kk;
}
else if(choi == 0) {
for (int i = 0; i < na.size(); i++) {
if(a[i] > na[i]){
ll kkk = (noa[i] / k);
if (kkk == 0)kkk++;
na[i] += k * kkk;
mp += x * kkk;
break;
}
}
}
}
cout << mp << endl;
return 0;
}