# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
11205 | 2014-11-18T16:27:15 Z | gs14004 | 중앙값 배열 (balkan11_medians) | C++ | 49 ms | 2952 KB |
#include <cstdio> struct bit{ int tree[270000], lim; void init(int n){ for(lim = 1; lim <= n; lim <<= 1); } void add(int x){ printf("%d ",x); while(x <= lim){ tree[x]++; x += x & -x; } } int sum(int x){ int res = 0; while(x){ res += tree[x]; x -= x & -x; } return res; } }bit; int v[200005]; int main(){ int n,t; scanf("%d",&n); bit.init(2*n); int lo = 1, hi = 2*n-1; scanf("%d",&t); bit.add(t); v[t] = 1; for (int i=1; i<n; i++) { scanf("%d",&t); int cnt = 0; if(!v[t]){ v[t] = 1; bit.add(t); cnt++; } while(bit.sum(t) < i+1){ while(v[lo]) lo++; v[lo] = 1; bit.add(lo); cnt++; } while(cnt < 2){ while(v[hi]) hi--; v[hi] = 1; bit.add(hi); cnt++; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2952 KB | Output is correct |
2 | Correct | 0 ms | 2952 KB | Output is correct |
3 | Correct | 0 ms | 2952 KB | Output is correct |
4 | Correct | 0 ms | 2952 KB | Output is correct |
5 | Correct | 0 ms | 2952 KB | Output is correct |
6 | Correct | 0 ms | 2952 KB | Output is correct |
7 | Correct | 0 ms | 2952 KB | Output is correct |
8 | Correct | 0 ms | 2952 KB | Output is correct |
9 | Correct | 0 ms | 2952 KB | Output is correct |
10 | Correct | 0 ms | 2952 KB | Output is correct |
11 | Correct | 0 ms | 2952 KB | Output is correct |
12 | Correct | 0 ms | 2952 KB | Output is correct |
13 | Correct | 0 ms | 2952 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2952 KB | Output is correct |
2 | Correct | 0 ms | 2952 KB | Output is correct |
3 | Correct | 3 ms | 2952 KB | Output is correct |
4 | Correct | 6 ms | 2952 KB | Output is correct |
5 | Correct | 9 ms | 2952 KB | Output is correct |
6 | Correct | 23 ms | 2952 KB | Output is correct |
7 | Correct | 49 ms | 2952 KB | Output is correct |