#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];
added[poz]=1;
k--;
int val=s[cnt];
while (cnt && val==s[cnt])
{
cnt--;
val++;
}
s[++cnt]=val;
}
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=s[cnt];
while (cnt && s[cnt]==val)
{
cnt--;
val++;
}
s[++cnt]=val;
}
assert (k>=0);
for (int i=1; i<=poz; i++)
{
if (added[poz])
{
descp (v[i]);
}
else g << v[i] << " ";
}
return 0;
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:25:16: warning: unused variable 'adaugate' [-Wunused-variable]
25 | int poz=0, adaugate=0;
| ^~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
8784 KB |
Execution killed with signal 6 |
2 |
Runtime error |
7 ms |
8784 KB |
Execution killed with signal 6 |
3 |
Runtime error |
9 ms |
8800 KB |
Execution killed with signal 6 |
4 |
Runtime error |
8 ms |
8784 KB |
Execution killed with signal 6 |
5 |
Runtime error |
7 ms |
8784 KB |
Execution killed with signal 6 |
6 |
Runtime error |
7 ms |
8916 KB |
Execution killed with signal 6 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
8784 KB |
Execution killed with signal 6 |
2 |
Runtime error |
7 ms |
8784 KB |
Execution killed with signal 6 |
3 |
Runtime error |
7 ms |
8732 KB |
Execution killed with signal 6 |
4 |
Runtime error |
7 ms |
8784 KB |
Execution killed with signal 6 |
5 |
Runtime error |
8 ms |
8784 KB |
Execution killed with signal 6 |
6 |
Runtime error |
8 ms |
8784 KB |
Execution killed with signal 6 |
7 |
Runtime error |
7 ms |
8784 KB |
Execution killed with signal 6 |
8 |
Runtime error |
9 ms |
8784 KB |
Execution killed with signal 6 |
9 |
Runtime error |
8 ms |
8784 KB |
Execution killed with signal 6 |
10 |
Runtime error |
8 ms |
8784 KB |
Execution killed with signal 6 |
11 |
Runtime error |
9 ms |
8784 KB |
Execution killed with signal 6 |
12 |
Runtime error |
7 ms |
8784 KB |
Execution killed with signal 6 |
13 |
Runtime error |
8 ms |
8784 KB |
Execution killed with signal 6 |
14 |
Runtime error |
9 ms |
8784 KB |
Execution killed with signal 6 |