# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
712103 | wenqi | Zalmoxis (BOI18_zalmoxis) | C++17 | 173 ms | 8408 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.
// trans rights
#include <bits/extc++.h>
using namespace std;
using ll = long long;
int N, K;
int inp[1000069];
stack<int> f;
vector<pair<int, int>> probes;
void probe(int x)
{
while (f.size() and x == f.top())
{
f.pop();
x++;
}
f.push(x);
}
void curse(int x, int &u)
{
if (x and u)
{
u--;
curse(x - 1, u);
curse(x - 1, u);
}else{
cout << x << ' ';
}
}
int main(int argc, const char *argv[])
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> K;
for (int i = 0; i <= N; i++)
{
int x = 30;
if (i < N)
cin >> x;
inp[i] = x;
while (f.size() and x > f.top())
{
probes.emplace_back(f.top(), i);
probe(f.top());
}
if (i < N)
probe(x);
}
int lo = K - probes.size();
int ptr = 0;
for (int i = 0; i <= N; i++)
{
while (ptr < probes.size() and probes[ptr].second <= i)
{
curse(probes[ptr].first, lo);
ptr++;
}
if (i < N)
cout << inp[i] << ' ';
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |