# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64313 | kylych03 | Zalmoxis (BOI18_zalmoxis) | C++14 | 463 ms | 33196 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# 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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |