# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
50207 | 2018-06-08T10:06:22 Z | rondojim | 중앙값 배열 (balkan11_medians) | C++17 | 138 ms | 22620 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; int A[2 * MAXN], B[MAXN], N, vis[2 * MAXN]; set<int> S; int main(){ scanf("%d", &N); for(int i=1; i<=N; ++i) scanf("%d", &B[i]); for(int i=1; i<2*N; ++i) S.insert(i); for(int i=1; i<N; ++i){ if(S.find(B[i]) != S.end()) S.erase(S.find(B[i])); } A[1] = B[1]; for(int i=N; i>=2; --i){ int p = B[i - 1], c = B[i]; set<int>::iterator it; if(c > p){ for(int j=2*i-1; j>=2*i-2; --j){ auto it = S.lower_bound(B[i]); A[j] = *it; S.erase(it); } } else if(c < p){ for(int j=2*i-1; j>=2*i-2; --j){ it = S.lower_bound(B[i - 1]); if(*it > B[i - 1]) --it; A[j] = *it; S.erase(it); } } else{ it = S.upper_bound(B[i]); A[2 * i - 1] = *it; S.erase(it); it = S.lower_bound(B[i]); if(*it >= B[i]) --it; A[2 * i - 2] = *it; S.erase(it); } if(!vis[B[i - 1]]){ S.insert(B[i - 1]); vis[B[i - 1]] = 1; } } for(int i=1; i<2*N; ++i) printf("%d ", A[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | Not a permutation |
2 | Runtime error | 5 ms | 868 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Runtime error | 5 ms | 1004 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
4 | Runtime error | 5 ms | 1004 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Runtime error | 4 ms | 1048 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 4 ms | 1048 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 5 ms | 1060 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
8 | Runtime error | 5 ms | 1064 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Runtime error | 5 ms | 1064 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
10 | Runtime error | 5 ms | 1084 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
11 | Runtime error | 5 ms | 1104 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
12 | Runtime error | 5 ms | 1228 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
13 | Runtime error | 6 ms | 1228 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 1484 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Runtime error | 9 ms | 1868 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Runtime error | 13 ms | 2764 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
4 | Runtime error | 20 ms | 4556 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Runtime error | 36 ms | 8012 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 77 ms | 14796 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 138 ms | 22620 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |