# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
544742 | rainboy | Zalmoxis (BOI18_zalmoxis) | C11 | 196 ms | 9568 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#define N 1000000
#define M 30
int k;
void print(int a) {
if (a == 0 || k == 0) {
printf("%d ", a);
return;
}
k--;
print(a - 1), print(a - 1);
}
int main() {
static int aa[N], qu[M + 1];
static char fixed[N];
int n, n_, i, cnt;
scanf("%d%d", &n, &k);
n_ = 0, cnt = 0;
for (i = 0; i < n; i++) {
int a;
scanf("%d", &a);
while (cnt && qu[cnt - 1] < a) {
while ((cnt < 2 || qu[cnt - 1] < qu[cnt - 2]) && qu[cnt - 1] < a)
aa[n_++] = qu[cnt - 1]++;
while (cnt >= 2 && qu[cnt - 1] == qu[cnt - 2])
qu[--cnt - 1]++;
}
qu[cnt++] = a;
while (cnt >= 2 && qu[cnt - 1] == qu[cnt - 2])
qu[--cnt - 1]++;
aa[n_] = a, fixed[n_] = 1, n_++;
}
while (cnt >= 2) {
aa[n_++] = qu[cnt - 1]++;
while (cnt >= 2 && qu[cnt - 1] == qu[cnt - 2])
qu[--cnt - 1]++;
}
while (qu[cnt - 1] < M)
aa[n_++] = qu[cnt - 1]++;
k -= n_ - n, n = n_;
for (i = 0; i < n; i++)
if (fixed[i])
printf("%d ", aa[i]);
else
print(aa[i]);
printf("\n");
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |