# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1108702 | vicvic | Zalmoxis (BOI18_zalmoxis) | C++11 | 2 ms | 4604 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 <iostream>
#include <fstream>
#include <cassert>
using namespace std;
ifstream f ("zalmoxis.in");
ofstream g ("zalmoxis.out");
int n, k, v[2000005], poz, added[2000005], s[2000005], cnt;
void descp (int j)
{
if (j<=1)
{
g << j << " ";
}
else if (k>0)
{
k--;
descp (j-1);
descp (j-1);
}
else g << j << " ";
}
int main()
{
f >> n >> k;
int poz=0, adaugate=0;
for (int i=1; i<=n; i++)
{
int x;
f >> x;
while (cnt && s[cnt]<x)
{
v[++poz]=s[cnt];
k--;
int val=v[poz];
while (cnt && val==s[cnt])
{
cnt--;
val++;
}
s[++cnt]=val;
added[poz]=1;
}
v[++poz]=x;
while (cnt && x==s[cnt])
{
cnt--;
x++;
}
s[++cnt]=x;
}
while (s[1]<30)
{
k--;
v[++poz]=s[cnt];
added[poz]=1;
int val=v[poz];
while (cnt && s[cnt]==val)
{
cnt--;
val++;
}
s[++cnt]=val;
}
for (int i=1; i<=poz; i++)
{
if (added[poz])
{
descp (v[i]);
}
else g << v[i] << " ";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |