# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26657 | 2017-07-04T13:18:18 Z | top34051 | medians (balkan11_medians) | C++14 | 69 ms | 2996 KB |
#include<bits/stdc++.h> using namespace std; int n; bool ok[200005]; int tree[200005]; void add(int x,int val) { while(x<=2*n-1) { tree[x] += val; x += x&-x; } } int sum(int x) { int ans = 0; while(x) { ans += tree[x]; x -= x&-x; } return ans; } main() { int i,j,x,sz; scanf("%d",&n); i = 1; j = 2*n-1; for(sz=1;sz<=2*n-1;sz+=2) { scanf("%d",&x); if(!ok[x]) { ok[x] = 1; add(x,1); printf("%d ",x); } while(sum(x-1)<sz/2) { while(ok[i]) i++; ok[i] = 1; add(i,1); printf("%d ",i); } while(sum(2*n-1)-sum(x)<sz/2) { while(ok[j]) j--; ok[j] = 1; add(j,1); printf("%d ",j); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2996 KB | Output is correct |
2 | Correct | 0 ms | 2996 KB | Output is correct |
3 | Correct | 0 ms | 2996 KB | Output is correct |
4 | Correct | 0 ms | 2996 KB | Output is correct |
5 | Correct | 0 ms | 2996 KB | Output is correct |
6 | Correct | 0 ms | 2996 KB | Output is correct |
7 | Correct | 0 ms | 2996 KB | Output is correct |
8 | Correct | 0 ms | 2996 KB | Output is correct |
9 | Correct | 0 ms | 2996 KB | Output is correct |
10 | Correct | 0 ms | 2996 KB | Output is correct |
11 | Correct | 0 ms | 2996 KB | Output is correct |
12 | Correct | 0 ms | 2996 KB | Output is correct |
13 | Correct | 0 ms | 2996 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2996 KB | Output is correct |
2 | Correct | 0 ms | 2996 KB | Output is correct |
3 | Correct | 3 ms | 2996 KB | Output is correct |
4 | Correct | 6 ms | 2996 KB | Output is correct |
5 | Correct | 19 ms | 2996 KB | Output is correct |
6 | Correct | 29 ms | 2996 KB | Output is correct |
7 | Correct | 69 ms | 2996 KB | Output is correct |