# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
111534 | Hideo | Zalmoxis (BOI18_zalmoxis) | C++14 | 1008 ms | 263168 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;
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define vl vector < ll >
#define pi pair < int, int >
#define pl pair < ll, ll >
#define pii pair < int, pi >
#define vii vector < pi >
const int N = 1e6 + 7;
const int INF = 1e9;
int a[N];
int n, k, it;
vector < int > ans;
void waste (int val){
if (val == 0)
ans.pb(0);
else if (k){
k--;
waste(val - 1);
waste(val - 1);
}
else
ans.pb(val);
}
void build (int val = 30){
if (a[it] == val && it <= n){
it++;
ans.pb(val);
}
else if (a[it] > val || it > n){
k--;
waste(val);
}
else if (val != 0){
build(val - 1);
build(val - 1);
}
else
ans.pb(0);
}
main(){
it++;
cin >> n >> k;
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
build();
for (int out : ans)
printf("%d ", out);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |