# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
35182 | 2017-11-18T15:45:28 Z | cheater2k | 중앙값 배열 (balkan11_medians) | C++14 | 46 ms | 4552 KB |
#include <bits/stdc++.h> using namespace std; const int N = 200005; int n, a[N], b[N]; int T[N]; bool used[N]; void upd(int x) { for(; x < N; x += x & -x) T[x]++; } int get(int x) { int res = 0; for (; x > 0; x -= x & -x) res += T[x]; return res; } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", b + i); int l = 1, r = 2 * n - 1; int pt = 0; for (int i = 1; i <= n; ++i) { if (!used[b[i]]) used[b[i]] = 1, a[++pt] = b[i], upd(b[i]); while(l <= 2 * n - 1 && used[l]) ++l; while(r >= 1 && used[r]) --r; int med = b[i]; while(pt < 2 * i - 1) { int smaller = get(med - 1); if (smaller < i - 1) a[++pt] = l, upd(l), used[l++] = 1; else if (pt - smaller < i) a[++pt] = r, upd(r), used[r--] = 1; } } for (int i = 1; i <= 2 * n - 1; ++i) printf("%d ", a[i]); printf("\n"); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4552 KB | Output is correct |
2 | Correct | 0 ms | 4552 KB | Output is correct |
3 | Incorrect | 0 ms | 4552 KB | Not a permutation |
4 | Incorrect | 0 ms | 4552 KB | Not a permutation |
5 | Incorrect | 0 ms | 4552 KB | Not a permutation |
6 | Correct | 0 ms | 4552 KB | Output is correct |
7 | Incorrect | 0 ms | 4552 KB | Not a permutation |
8 | Incorrect | 0 ms | 4552 KB | Not a permutation |
9 | Incorrect | 0 ms | 4552 KB | Not a permutation |
10 | Correct | 0 ms | 4552 KB | Output is correct |
11 | Incorrect | 0 ms | 4552 KB | Not a permutation |
12 | Incorrect | 0 ms | 4552 KB | Not a permutation |
13 | Incorrect | 0 ms | 4552 KB | Not a permutation |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 4552 KB | Not a permutation |
2 | Incorrect | 0 ms | 4552 KB | Not a permutation |
3 | Incorrect | 3 ms | 4552 KB | Not a permutation |
4 | Incorrect | 6 ms | 4552 KB | Not a permutation |
5 | Incorrect | 6 ms | 4552 KB | Not a permutation |
6 | Incorrect | 26 ms | 4552 KB | Not a permutation |
7 | Incorrect | 46 ms | 4552 KB | Not a permutation |