# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336233 | ttnhuy313 | Zalmoxis (BOI18_zalmoxis) | C++14 | 235 ms | 29488 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 int long long
typedef pair <int, int> ii;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, k; cin >> n >> k;
int rem = n + k, x;
stack <int> s, cur;
stack <ii> ans;
for(int i = 0; i < n; i++){
cin >> x;
s.push(x);
}
cur.push(30);
while (!s.empty()){
if (cur.top() <= s.top()){
ans.push(ii(cur.top(), cur.top() == s.top()));
if (s.top() == cur.top()) s.pop();
cur.pop();
} else{
int x = cur.top();
cur.pop();
cur.push(x - 1);
cur.push(x - 1);
}
}
while (!cur.empty()) {
ans.push(ii(cur.top(),0));
cur.pop();
}
vector <int> fans;
while (rem > 0){
if (ans.size() == rem || ans.top().second == 1 || ans.top().first==0){
fans.push_back(ans.top().first);
ans.pop();
rem--;
} else{
x = ans.top().first;
ans.pop();
ans.push(ii(x - 1,0));
ans.push(ii(x - 1,0));
}
}
for(int i = 0; i < n + k; i++){
cout << fans[i] << " ";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |