# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
201187 | 2020-02-09T17:14:23 Z | Shelby | Zalmoxis (BOI18_zalmoxis) | C++11 | 1000 ms | 10504 KB |
#include <bits/stdc++.h> #define MAXN 1000005 using namespace std; int a[MAXN]; vector<int> sol; vector<int> ans; deque<int> d; deque<int> r; deque<int> pom; int main() { int n,k,i; scanf("%d%d",&n,&k); for(i=1;i<=n;i++) { scanf("%d",&a[i]); r.push_back(a[i]); } d.push_back(30); while(!r.empty()) { while(d.back()>r.back()) { int x=d.back(); d.pop_back(); if(x>1) { d.push_back(x-1); d.push_back(x-1); } } while(!r.empty() && d.back()<=r.back()) { if(!r.empty() && d.back()==r.back()) { sol.push_back(d.back()); d.pop_back(); r.pop_back(); } if(!r.empty() && d.back()<r.back()) { sol.push_back(d.back()); d.pop_back(); } } } while(!d.empty()) { sol.push_back(d.back()); d.pop_back(); } //reverse(sol.begin(),sol.end()); for(i=0;i<sol.size();i++) pom.push_back(sol[i]); int cnt=n+k-sol.size(); int poz=n; if(cnt==0) ans.insert(ans.end(),sol.begin(),sol.end()); while(cnt>0) { while(pom.back()==a[poz] && poz>0) { ans.push_back(a[poz]); poz--; pom.pop_back(); } while(cnt>0 && pom.back()!=a[poz]) { int x=pom.back(); pom.pop_back(); deque<int> tmpl; tmpl.push_back(x); while(!tmpl.empty() && cnt>0) { if(!tmpl.empty() && tmpl.back()==1) { ans.push_back(1); tmpl.pop_back(); } else { while(!tmpl.empty() && tmpl.back()!=1 && cnt>0) { int y=tmpl.back(); tmpl.pop_back(); //cout << tmpl.size() << endl; tmpl.push_back(y-1); tmpl.push_back(y-1); cnt--; } while(cnt==0 && !tmpl.empty()) { ans.push_back( tmpl.back() ); tmpl.pop_back(); } } } } } reverse(ans.begin(),ans.end()); for(i=0;i<ans.size();i++) printf("%d ",ans[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1076 ms | 10360 KB | Time limit exceeded |
2 | Execution timed out | 1024 ms | 10360 KB | Time limit exceeded |
3 | Execution timed out | 1063 ms | 10464 KB | Time limit exceeded |
4 | Execution timed out | 1058 ms | 10360 KB | Time limit exceeded |
5 | Execution timed out | 1061 ms | 10360 KB | Time limit exceeded |
6 | Execution timed out | 1038 ms | 10360 KB | Time limit exceeded |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1072 ms | 10488 KB | Time limit exceeded |
2 | Execution timed out | 1072 ms | 10360 KB | Time limit exceeded |
3 | Execution timed out | 1025 ms | 10360 KB | Time limit exceeded |
4 | Execution timed out | 1056 ms | 10504 KB | Time limit exceeded |
5 | Execution timed out | 1062 ms | 10360 KB | Time limit exceeded |
6 | Execution timed out | 1032 ms | 10360 KB | Time limit exceeded |
7 | Execution timed out | 1051 ms | 10364 KB | Time limit exceeded |
8 | Execution timed out | 1074 ms | 10360 KB | Time limit exceeded |
9 | Execution timed out | 1036 ms | 8440 KB | Time limit exceeded |
10 | Execution timed out | 1055 ms | 3320 KB | Time limit exceeded |
11 | Execution timed out | 1054 ms | 5368 KB | Time limit exceeded |
12 | Execution timed out | 1078 ms | 256 KB | Time limit exceeded |
13 | Execution timed out | 1090 ms | 256 KB | Time limit exceeded |
14 | Incorrect | 116 ms | 6364 KB | Unexpected end of file - int32 expected |