Submission #64313

#TimeUsernameProblemLanguageResultExecution timeMemory
64313kylych03Zalmoxis (BOI18_zalmoxis)C++14
100 / 100
463 ms33196 KiB
# include <bits/stdc++.h> using namespace std; vector < int > vec[1000001]; int cnt=0; void fun(int i,int j){ if(cnt<=0) return; if(vec[i].size()<=j) return; if(vec[i][j]<=0) { fun(i,j+1); return; } vec[i][j]--; vec[i].insert(vec[i].begin()+j, vec[i][j]); cnt--; fun(i,j); } int main(){ int n,k,i,a[1000001]; cin>>n>>k; for(i=0;i<n;i++) cin>>a[i]; deque <int> dq; dq.push_back(30); i=0; while(i<n){ if(dq.front() > a[i]){ dq.front()--; dq.push_front(dq.front()); } else if(dq.front()==a[i]){ i++; dq.pop_front(); } else if(dq.front() < a[i]){ vec[i].push_back(dq.front()); dq.pop_front(); cnt++; } } while(dq.size()>0){ vec[n].push_back(dq.front()); dq.pop_front(); cnt++; } cnt=k-cnt; for(i=0;i<=n;i++){ if(cnt!=0 && vec[i].size()>0) fun(i,0); } for(i=0;i<n;i++){ for(int j=0;j<vec[i].size();j++) cout<<vec[i][j]<<" "; cout<<a[i]<<" "; } for(int j=0;j<vec[n].size();j++) cout<<vec[n][j]<<" "; }

Compilation message (stderr)

zalmoxis.cpp: In function 'void fun(int, int)':
zalmoxis.cpp:9:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(vec[i].size()<=j)
     ~~~~~~~~~~~~~^~~
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:67:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<vec[i].size();j++)
               ~^~~~~~~~~~~~~~
zalmoxis.cpp:71:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j=0;j<vec[n].size();j++)
              ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...