Submission #644350

#TimeUsernameProblemLanguageResultExecution timeMemory
644350KriptonZalmoxis (BOI18_zalmoxis)C++14
30 / 100
146 ms34876 KiB
#include <bits/stdc++.h> using namespace std; int steve[1000001],vf; int steve1[1000001],vf1; int v[1000001],v1[1000001]; vector <int> addie[1000001]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,k,i,x,j; cin>>n>>k; for(i=1;i<=n;i++) { cin>>v[i]; v1[i]=v[i]; while(v[i]==v[steve[vf]]) { v[i]++; vf--; } steve[++vf]=i; } for(j=1;j<=30&&k&&v[steve[vf]]!=30;j++) { int min1=40,ind; for(i=1;i<=vf;i++) min1=min(min1,v[steve[i]]); vf1=0; for(i=1;i<=vf;i++) { if(k&&v[steve[i]]==min1) { k--; v[steve[i]]++; addie[steve[i]].push_back(min1); } while(v[steve[i]]==v[steve1[vf1]]) { v[steve[i]]++; vf1--; } steve1[++vf1]=steve[i]; } vf=vf1; for(i=1;i<=vf;i++) steve[i]=steve1[vf1]; } for(i=1;i<=n;i++) { cout<<v1[i]<<" "; for(auto it:addie[i]) { if(k>=((1<<it)-1)) { k-=((1<<it)-1); for(j=1;j<=(1<<it);j++) cout<<"1 "; continue; } else if(k) { int a=(int)log2(k)+1; int newit=it-a; //daca fac (1<<a) newit-uri, k-=((1<<(a+1))-1) k-=((1<<a)-1); k=-k; for(j=1;j<=(1<<a)-2*k;j++) cout<<newit<<" "; for(j=1;j<=k;j++) cout<<newit+1<<" "; k=0; } else cout<<it<<" "; } } return 0; }

Compilation message (stderr)

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:27:21: warning: unused variable 'ind' [-Wunused-variable]
   27 |         int min1=40,ind;
      |                     ^~~
zalmoxis.cpp:12:15: warning: unused variable 'x' [-Wunused-variable]
   12 |     int n,k,i,x,j;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...