제출 #544742

#제출 시각아이디문제언어결과실행 시간메모리
544742rainboyZalmoxis (BOI18_zalmoxis)C11
100 / 100
196 ms9568 KiB
#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) 메시지

zalmoxis.c: In function 'main':
zalmoxis.c:22:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d%d", &n, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~
zalmoxis.c:27:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%d", &a);
      |   ^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...