| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 26657 | top34051 | 중앙값 배열 (balkan11_medians) | C++14 | 69 ms | 2996 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
