# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
60768 | 2018-07-24T16:15:15 Z | alenam0161 | Zalmoxis (BOI18_zalmoxis) | C++17 | 338 ms | 12448 KB |
#include <bits/stdc++.h> void fl(); using namespace std; const int N = 1000000+7; int a[N]; stack<int> st; vector<int> ans; void rem(){ while(st.size()>=2){ int z=st.top(); st.pop(); if(z==st.top()){ st.pop(); st.push(z+1); } else{ st.push(z); break; } } } int main(){ int n,k; scanf("%d %d",&n,&k); for(int i=0;i<n;++i){ scanf("%d",a+i); } int s=k; st.push(a[0]); ans.push_back(a[0]); for(int i=1;i<n;++i){ while(a[i]>st.top()){ int x=st.top(); ans.push_back(x); st.push(x); rem(); k--; } ans.push_back(a[i]); st.push(a[i]); rem(); } while(st.size()!=1){ ans.push_back(st.top()); st.push(st.top()); rem(); k--; } int z=st.top(); while(k>0){ ans.push_back(z); z--; k--; } if(ans.size()!=s+n){ assert(0); } for(int i=0;i<ans.size();++i){ printf("%d ",ans[i]); } return 0; } void fl(){ freopen("input.txt","r",stdin); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 337 ms | 10432 KB | Output is correct |
2 | Correct | 273 ms | 10564 KB | Output is correct |
3 | Correct | 271 ms | 10564 KB | Output is correct |
4 | Correct | 264 ms | 10564 KB | Output is correct |
5 | Correct | 236 ms | 10572 KB | Output is correct |
6 | Correct | 256 ms | 10580 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 303 ms | 10580 KB | not a zalsequence |
2 | Correct | 268 ms | 10644 KB | Output is correct |
3 | Incorrect | 234 ms | 10644 KB | not a zalsequence |
4 | Incorrect | 252 ms | 10644 KB | not a zalsequence |
5 | Incorrect | 230 ms | 10644 KB | not a zalsequence |
6 | Incorrect | 216 ms | 10644 KB | not a zalsequence |
7 | Incorrect | 297 ms | 10712 KB | not a zalsequence |
8 | Incorrect | 289 ms | 10712 KB | not a zalsequence |
9 | Incorrect | 338 ms | 10712 KB | not a zalsequence |
10 | Incorrect | 180 ms | 11024 KB | not a zalsequence |
11 | Incorrect | 241 ms | 11024 KB | not a zalsequence |
12 | Incorrect | 130 ms | 12432 KB | not a zalsequence |
13 | Incorrect | 130 ms | 12432 KB | not a zalsequence |
14 | Incorrect | 123 ms | 12448 KB | not a zalsequence |