結果
問題 | No.1071 ベホマラー |
ユーザー |
|
提出日時 | 2020-06-05 22:48:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,185 bytes |
コンパイル時間 | 1,008 ms |
コンパイル使用メモリ | 86,736 KB |
実行使用メモリ | 19,408 KB |
最終ジャッジ日時 | 2024-12-17 16:58:47 |
合計ジャッジ時間 | 41,193 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 7 TLE * 13 |
ソースコード
#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; }