# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
27494 | 2017-07-13T07:55:15 Z | TAMREF | 중앙값 배열 (balkan11_medians) | C++11 | 136 ms | 11784 KB |
#include <bits/stdc++.h> using namespace std; const int mx=100005; int B[mx]; 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(){ printf("%d ",B[0]); L.erase(B[0]); for(int i=1;i<N;i++){ if(B[i]==B[i-1]){ printf("%d ",*L.begin()); L.erase(*L.begin()); printf("%d ",*L.rbegin()); L.erase(*L.rbegin()); } else if(B[i]<B[i-1]){ if(L.find(B[i])==L.end()){ printf("%d ",*L.begin()); L.erase(*L.begin()); printf("%d ",*L.begin()); L.erase(*L.begin()); }else{ printf("%d ",B[i]); L.erase(B[i]); printf("%d ",*L.begin()); L.erase(*L.begin()); } } else{ if(L.find(B[i])==L.end()){ printf("%d ",*L.rbegin()); L.erase(*L.rbegin()); printf("%d ",*L.rbegin()); L.erase(*L.rbegin()); }else{ printf("%d ",B[i]); L.erase(B[i]); printf("%d ",*L.rbegin()); L.erase(*L.rbegin()); } } } } int main(){ input(); solve(); return 0&puts(""); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2412 KB | Output is correct |
2 | Correct | 0 ms | 2412 KB | Output is correct |
3 | Correct | 0 ms | 2412 KB | Output is correct |
4 | Correct | 0 ms | 2412 KB | Output is correct |
5 | Correct | 0 ms | 2412 KB | Output is correct |
6 | Correct | 0 ms | 2412 KB | Output is correct |
7 | Correct | 0 ms | 2412 KB | Output is correct |
8 | Correct | 0 ms | 2412 KB | Output is correct |
9 | Correct | 0 ms | 2412 KB | Output is correct |
10 | Correct | 0 ms | 2412 KB | Output is correct |
11 | Correct | 0 ms | 2412 KB | Output is correct |
12 | Correct | 0 ms | 2544 KB | Output is correct |
13 | Correct | 0 ms | 2544 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 2676 KB | Output is correct |
2 | Correct | 3 ms | 2808 KB | Output is correct |
3 | Correct | 6 ms | 3204 KB | Output is correct |
4 | Correct | 13 ms | 3864 KB | Output is correct |
5 | Correct | 36 ms | 5448 KB | Output is correct |
6 | Correct | 79 ms | 8484 KB | Output is correct |
7 | Correct | 136 ms | 11784 KB | Output is correct |