# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1108716 | vicvic | Zalmoxis (BOI18_zalmoxis) | C++11 | 121 ms | 24520 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;
ifstream f ("zalmoxis.in");
ofstream g ("zalmoxis.out");
int n, k, v[1000005], poz, added[1000005], s[1000005], cnt;
void descp (int j)
{
if (j<=1)
{
cout << j << " ";
}
else if (k>0)
{
k--;
descp (j-1);
descp (j-1);
}
else cout << j << " ";
}
void propag ()
{
while (cnt>=2)
{
int a=s[cnt], b=s[cnt-1];
if (a==b)
{
cnt--;
s[cnt]=a+1;
}
else
{
return;
}
}
}
int main()
{
cin >> n >> k;
int poz=0, adaugate=0;
for (int i=1; i<=n; i++)
{
int x;
cin >> x;
while (cnt && s[cnt]<x)
{
v[++poz]=s[cnt];
added[poz]=1;
k--;
s[++cnt]=s[cnt-1];
propag ();
}
v[++poz]=x;
s[++cnt]=x;
propag ();
}
while (s[1]<30)
{
k--;
v[++poz]=s[cnt];
added[poz]=1;
s[++cnt]=s[cnt-1];
propag ();
}
for (int i=1; i<=poz; i++)
{
if (added[poz])
{
descp (v[i]);
}
else cout << v[i] << " ";
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |