# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
668177 | MrDeboo | Zalmoxis (BOI18_zalmoxis) | C++17 | 116 ms | 42668 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>;
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
deque<int>a,b(n);
for(auto &i:b)cin>>i;
deque<int>doq=b;
deque<int>dq={b[0]};
a.push_back(b[0]);
b.pop_front();
while(b.size()){
if(b[0]<=a.back()){
a.push_back(b[0]);
dq.push_back(b[0]);
b.pop_front();
}else{
k--;
a.push_back(a.back());
dq.push_back(a.back());
}
while(a.size()>1&&a.back()==a[a.size()-2]){
int A=a.back();
a.pop_back();
a.pop_back();
a.push_back(A+1);
}
}
while(a.size()>1){
a.push_back(a.back());
dq.push_back(a.back());
k--;
while(a.size()>1&&a.back()==a[a.size()-2]){
int A=a.back();
a.pop_back();
a.pop_back();
a.push_back(A+1);
}
}
assert(k>=0);
int g=a.back();
while(k--){
dq.push_back(g++);
}
int f=0;
for(int i=0;i<dq.size();i++){
if(f<doq.size()&&doq[f]==dq[i])f++;
}
deque<int>deq;
for(int i=0;i<dq.size();i++){
deq.push_back(dq[i]);
while(deq.size()>1&&deq.back()==deq[deq.size()-2]){
int a=deq.back();
deq.pop_back();
deq.pop_back();
deq.push_back(a);
}
}
assert(deq.size()==1);
for(auto &i:dq)cout<<i<<' ';
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |