# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
60721 | 2018-07-24T15:14:05 Z | alenam0161 | Zalmoxis (BOI18_zalmoxis) | C++17 | 355 ms | 11452 KB |
#include <bits/stdc++.h> void fl(); using namespace std; const int N = 1000000+7; int a[N]; int main(){ int n,k; scanf("%d %d",&n,&k); for(int i=0;i<n;++i){ scanf("%d",a+i); } stack<int> st; st.push(a[0]); vector<int> ans; ans.push_back(a[0]); for(int i=1;i<n;++i){ if(a[i]>=st.top()){ while(a[i]>=st.top()){ int x=st.top(); ans.push_back(x); st.pop(); st.push(x+1); 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; } } k--; } k++; } else{ ans.push_back(a[i]); st.push(a[i]); } } while(st.size()>1){ int x=st.top(); st.pop(); int y=st.top(); while(x<=y){ ans.push_back(x); x++; k--; } st.pop(); st.push(x); k++; } int z=st.top(); while(k>0){ ans.push_back(z); z++; k--; } for(int i=0;i<ans.size();++i){ printf("%d ",ans[i]); } return 0; } void fl(){ freopen("input.txt","r",stdin); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 293 ms | 10392 KB | Expected EOF |
2 | Incorrect | 226 ms | 10484 KB | Expected EOF |
3 | Incorrect | 267 ms | 10576 KB | Expected EOF |
4 | Incorrect | 236 ms | 10588 KB | Expected EOF |
5 | Incorrect | 313 ms | 10620 KB | Expected EOF |
6 | Incorrect | 355 ms | 10620 KB | Expected EOF |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 325 ms | 10620 KB | Expected EOF |
2 | Incorrect | 242 ms | 10620 KB | Expected EOF |
3 | Incorrect | 243 ms | 10620 KB | Expected EOF |
4 | Incorrect | 269 ms | 10740 KB | Expected EOF |
5 | Incorrect | 258 ms | 10740 KB | Expected EOF |
6 | Incorrect | 274 ms | 10740 KB | Expected EOF |
7 | Incorrect | 291 ms | 10740 KB | Expected EOF |
8 | Incorrect | 312 ms | 10740 KB | Expected EOF |
9 | Incorrect | 200 ms | 10740 KB | Expected EOF |
10 | Incorrect | 310 ms | 10772 KB | Expected EOF |
11 | Incorrect | 249 ms | 10772 KB | Expected EOF |
12 | Incorrect | 123 ms | 11408 KB | Expected EOF |
13 | Incorrect | 122 ms | 11452 KB | Expected EOF |
14 | Incorrect | 132 ms | 11452 KB | not a zalsequence |