# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
217662 | 2020-03-30T11:42:00 Z | KoalaMuch | 중앙값 배열 (balkan11_medians) | C++14 | 120 ms | 13560 KB |
#include<bits/stdc++.h> using namespace std; const int N = 2e5+5; int f[N]; set< int > s; int ans[N]; int a[N]; int cur = 1; void upd(int i) { while(i<N) ++f[i],i+=i&-i; } int get(int i,int ret = 0) { while(i) ret+=f[i],i-=i&-i; return ret; } void add(int v) { ans[cur] = v; s.erase(s.find(v)); upd(v+1); cur++; } int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<2*n;i++) s.insert(i); for(int i=1;i<=n;i++) { if(s.count(a[i])) add(a[i]); if(get(a[i])!=i-1) add(*s.begin()); if(cur-get(a[i]+1)!=i) add(*(--s.end())); } for(int i=1;i<2*n;i++) printf("%d ",ans[i]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Integer 0 violates the range [1, 19] |
2 | Incorrect | 5 ms | 384 KB | Integer 0 violates the range [1, 39] |
3 | Incorrect | 5 ms | 384 KB | Integer 0 violates the range [1, 59] |
4 | Incorrect | 5 ms | 384 KB | Integer 0 violates the range [1, 79] |
5 | Incorrect | 5 ms | 384 KB | Integer 0 violates the range [1, 99] |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Incorrect | 5 ms | 384 KB | Integer 0 violates the range [1, 139] |
8 | Incorrect | 5 ms | 384 KB | Integer 0 violates the range [1, 159] |
9 | Incorrect | 5 ms | 384 KB | Integer 0 violates the range [1, 179] |
10 | Incorrect | 5 ms | 384 KB | Integer 0 violates the range [1, 199] |
11 | Incorrect | 5 ms | 384 KB | Integer 0 violates the range [1, 599] |
12 | Incorrect | 5 ms | 512 KB | Integer 0 violates the range [1, 1199] |
13 | Incorrect | 5 ms | 512 KB | Integer 0 violates the range [1, 1999] |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 640 KB | Integer 0 violates the range [1, 3999] |
2 | Incorrect | 9 ms | 896 KB | Integer 0 violates the range [1, 7999] |
3 | Incorrect | 12 ms | 1408 KB | Integer 0 violates the range [1, 15999] |
4 | Incorrect | 20 ms | 2424 KB | Integer 0 violates the range [1, 31999] |
5 | Incorrect | 37 ms | 4472 KB | Integer 0 violates the range [1, 63999] |
6 | Incorrect | 73 ms | 8696 KB | Integer 0 violates the range [1, 127999] |
7 | Incorrect | 120 ms | 13560 KB | Integer 0 violates the range [1, 199999] |