| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1286624 | thuhienne | Zalmoxis (BOI18_zalmoxis) | C++20 | 859 ms | 145312 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define re exit(0);
#define thuhien "zalmosis"
int n,k;
vector <int> s;
struct range {
int val;
vector <pair <int,bool>> container;
};
vector <range> arr,temp;
multiset <int> a;
multiset <int>::iterator it;
void print(int val) {
a.clear();
a.insert(val);
while (k && *a.rbegin() != 1) {
it = a.end();it--;
a.insert(*it - 1);a.insert(*it - 1);
a.erase(it);
k--;
}
for (auto x : a) cout << x << " ";
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(nullptr);
if (fopen(thuhien".inp","r")) {
freopen(thuhien".inp","r",stdin);
freopen(thuhien".out","w",stdout);
}
cin >> n >> k;
arr.resize(n);
for (int i = 0;i < n;i++) {
int a;cin >> a;
arr[i] = {a,{{a,0}}};
}
for (int tt = 0;tt <= 29;tt++) {
temp.clear();
for (auto x : arr) {
if (temp.size() && temp.back().val == tt && x.val == tt) {
temp.back().val++;
for (auto a : x.container) temp.back().container.push_back(a);
} else temp.push_back(x);
}
arr.clear();
arr = temp;
for (int i = 0;i < arr.size();i++) if (arr[i].val == tt) {
arr[i].val++;
arr[i].container.push_back({tt,1});
k--;
}
}
for (auto x : arr[0].container) {
if (!x.second) cout << x.first << " ";
else print(x.first);
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
