Submission #1108082

#TimeUsernameProblemLanguageResultExecution timeMemory
1108082vicvicZalmoxis (BOI18_zalmoxis)C++11
0 / 100
1 ms4604 KiB
#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; int main() { f >> n >> k; int poz=0, adaugate=0; for (int i=1;i<=n;i++) { int x; f >> x; int ok=0; while (cnt && s[cnt]<x) { v[++poz]=s[cnt]; adaugate++; 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[cnt]!=30) { adaugate++; v[++poz]=s[cnt]; added[poz]=1; int val=v[poz]; while (cnt && s[cnt]==val) { cnt--; val++; } s[++cnt]=val; } k-=adaugate; int t=0; for (int i=1;i<=poz;i++) { if (added[poz] && k && v[i]>1) { int fp=max (v[i]-k, 1); int cate=min (v[i]-1, k); t++; g << fp << " "; for (int j=fp;j<=v[i]-2;j++) { t++; g << j << " "; } v[i]--; k-=cate; i--; continue; } t++; g << v[i] << " "; } assert (t!=n+k); return 0; }

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:16:13: warning: unused variable 'ok' [-Wunused-variable]
   16 |         int ok=0;
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...