이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <set>
using namespace std;
set<int> se;
int a[100005];
int b[200005];
int main()
{
int n,cnt=1;
cin>>n;
for(int i=1;i<=n;i++){
cin>>b[i];
}
for(int i=1;i<=2*n-1;i++){
se.insert(i);
}
a[1]=b[1];
se.erase(a[1]);
set<int>::iterator it;
for(int i=2;i<=n;i++){
if(b[i]==b[i-1]){
///trebuie bagate doua elemente, unu mai mare ca b[i],unu mai mic ca b[i]
///le bagam pe cel mai mare si cel mai mic element nefolosit
it=se.begin();
a[++cnt]=*it;
se.erase(it);
it=se.end();
it--;
a[++cnt]=*it;
se.erase(it);
}
else
if(b[i]>b[i-1]){
if(se.count(b[i])==0){
it=se.begin();
a[++cnt]=*it;
se.erase(it);
it=se.end();
it--;
a[++cnt]=*it;
se.erase(it);
///exista deja mijlocul
}
else{
se.erase(b[i]);
a[++cnt]=b[i];
it=se.end();
it--;
a[++cnt]=*it;
se.erase(it);
}
}
else{
if(se.count(b[i])==0){
it=se.begin();
a[++cnt]=*it;
se.erase(it);
it=se.end();
it--;
a[++cnt]=*it;
se.erase(it);
}
else{
se.erase(b[i]);
a[++cnt]=b[i];
it=se.begin();
a[++cnt]=*it;
se.erase(it);
}
}
}
for(int i=1;i<=2*n-1;i++)
cout<<a[i]<<" ";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |