# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647060 | georgievskiy | Zalmoxis (BOI18_zalmoxis) | C++17 | 319 ms | 27048 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
int main() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int &x : a) cin >> x;
vector<pii> t, q;
for (int i = 0; i < n; i++)
t.push_back({a[i], i});
for (int val = 0; val < 30; val++) {
vector<pii> nt;
for (int i = 0; i < t.size(); i++) {
if (t[i].first != val) {
nt.push_back(t[i]);
continue;
}
if (i + 1 < t.size() && t[i].first == t[i + 1].first) {
nt.push_back({t[i].first + 1, t[i + 1].second});
i++;
} else {
nt.push_back({t[i].first + 1, t[i].second});
q.push_back({t[i].second, t[i].first});
}
}
t = nt;
}
a.insert(a.begin() + q[0].first + 1, q[0].second);
for (int x : a)
cout << x << " ";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |