# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
27493 | TAMREF | 중앙값 배열 (balkan11_medians) | C++11 | 126 ms | 12568 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mx=100005;
int B[mx], A[mx<<1];
int N;
set<int> L;
void input(){
scanf("%d",&N);
for(int i=0;i<N;i++){
scanf("%d",&B[i]);
}
for(int i=0;i<2*N-1;i++) L.insert(i+1);
}
void solve(){
L.erase(B[0]);
A[0]=B[0];
for(int i=1;i<N;i++){
if(B[i]==B[i-1]){
A[2*i-1]=*L.begin(); L.erase(*L.begin());
A[2*i ]=*L.rbegin(); L.erase(*L.rbegin());
}
else if(B[i]<B[i-1]){
if(L.find(B[i])==L.end()){
A[2*i-1]=*L.begin(); L.erase(*L.begin());
A[2*i ]=*L.begin(); L.erase(*L.begin());
}else{
A[2*i-1]=B[i]; L.erase(B[i]);
A[2*i ]=*L.begin(); L.erase(*L.begin());
}
}
else{
if(L.find(B[i])==L.end()){
A[2*i-1]=*L.rbegin(); L.erase(*L.rbegin());
A[2*i ]=*L.rbegin(); L.erase(*L.rbegin());
}else{
A[2*i-1]=B[i]; L.erase(B[i]);
A[2*i ]=*L.rbegin(); L.erase(*L.rbegin());
}
}
}
}
int main(){
input();
solve();
for(int i=0;i<2*N-1;i++) printf("%d ",A[i]);
return 0&puts("");
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |