# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
668388 | Rifal | Zalmoxis (BOI18_zalmoxis) | C++14 | 153 ms | 7024 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>
//#include <fstream>
#define endl '\n'
#define mod 5000000
#define INF 100000000000000000
//define ll long long
//ofstream fout("split.out");
//ifstream fin("split.in");
//#define cin fin
//#define cout fout
#define fi first
#define se second
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, k ;cin >> n >> k; vector<int> v; stack<int> st;
for(int i = 0; i < n; i++) {
int x; cin >> x;
while(!st.empty() && st.top() < x) {
int z = st.top();
v.push_back(z);
while(z == st.top()) {
st.pop();
z++;
}
st.push(z);
}
st.push(x);
v.push_back(x);
int y = st.top(); st.pop();
while(!st.empty() && st.top() == y) {
st.pop();
y++;
}
if(y < 30) st.push(y);
}
while(!st.empty() && st.top() != 30) {
int y = st.top();
st.pop();
v.push_back(y);
y++;
while(!st.empty() && st.top()== y) {
st.pop(); y++;
}
if(y != 30) st.push(y);
}
for(int i = 0; i < v.size(); i++) {
cout << v[i] << ' ';
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |