# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1090771 | noyancanturk | Zalmoxis (BOI18_zalmoxis) | C++17 | 176 ms | 18248 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main(){
#ifdef Local
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
int n,k;
cin>>n>>k;
int s[n];
for(int i=0;i<n;i++)cin>>s[i];
vector<int>have;
vector<int>ans;
vector<int>mine;
have.pb(s[0]);
ans.pb(s[0]);
mine.pb(0);
for(int i=1;i<n;i++){
int cur=have.back();
have.pop_back();
while(cur<s[i]){
ans.pb(cur);
mine.pb(1);
k--;
cur++;
while(have.size()&&cur==have.back()){
have.pop_back();
cur++;
}
}
ans.pb(s[i]);
mine.pb(0);
if(cur==s[i]){
cur++;
while(have.size()&&have.back()==cur){
cur++;
have.pop_back();
}
have.pb(cur);
}else{
have.pb(cur);
have.pb(s[i]);
}
}
while(have.back()<30){
int val=have.back();
ans.push_back(val);
mine.push_back(1);
k--;
have.pop_back();
val++;
while(have.size()&&val==have.back()){
have.pop_back();
val++;
}
have.pb(val);
}
vector<int>realans;
for(int i=0;i<ans.size();i++){
if(!mine[i]){
realans.pb(ans[i]);
}else{
vector<int>gotten;
gotten.pb(ans[i]);
while(k&&gotten.size()){
if(gotten.back()==1){
realans.pb(gotten.back());
gotten.pop_back();
}else{
int val=gotten.back();
gotten.pop_back();
gotten.pb(val-1);
gotten.pb(val-1);
k--;
}
}
while(gotten.size()){
realans.pb(gotten.back());
gotten.pop_back();
}
}
}
for(int i:realans)cout<<i<<" ";
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |