This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int currmin, currmax, pre, n, tmp;
vector<bool> used;
int getmin(){
while(used[currmin])currmin++;
return currmin;
}
int getmax(){
while(used[currmax])currmax--;
return currmax;
}
void query(int x){
cout << x << " ";
used[x]=true;
}
int main(){
cin >> n;
used.assign(2*n, false);
currmin = 1;
currmax = 2*n-1;
cin >> tmp;
cout << tmp << " ";
used[tmp]=true;
pre = tmp;
for(int i = 0; i < n-1; i++){
cin >> tmp;
if(tmp > pre){
query(tmp);
query(getmax());
}
else if(tmp < pre){
query(tmp);
query(getmin());
}
else{
query(getmin());
query(getmax());
}
pre = tmp;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |