# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61910 | khsoo01 | Zalmoxis (BOI18_zalmoxis) | C++11 | 379 ms | 10740 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;
typedef pair<int,int> pii;
int n, k;
vector<int> cur;
vector<pii> ans;
void upd () {
while(cur.size() >= 2) {
int A = cur.back();
cur.pop_back();
int B = cur.back();
cur.pop_back();
if(A != B) {
cur.push_back(B);
cur.push_back(A);
return;
}
else cur.push_back(A+1);
}
}
void print (int V) {
if(V && k) {
k--;
print(V-1);
print(V-1);
}
else {
printf("%d ",V);
return;
}
}
int main()
{
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++) {
int T;
scanf("%d",&T);
while(!cur.empty() && T > cur.back()) {
ans.push_back({cur.back(), 1});
k--;
cur.push_back(cur.back());
upd();
}
ans.push_back({T, 0});
cur.push_back(T);
upd();
}
while(cur[0] < 30) {
ans.push_back({cur.back(), 1});
k--;
cur.push_back(cur.back());
upd();
}
for(auto &T : ans) {
int A, B;
tie(A, B) = T;
if(B) print(A);
else printf("%d ",A);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |