#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;
int c[32001];
int a[15010];
int lowbit(int x){
return x&(-x);
}
void modify(int i){
while(i<=32001){
c[i]++;
i+=lowbit(i);
}
}
int sum(int i){
int s=0;
while(i>0){
s+=c[i];
i-=lowbit(i);
}
return s;
}
int main(){
int n;
scanf("%d",&n);
int x,y;
for(int i=1;i<=n;i++){
scanf("%d%d",&x,&y);
a[sum(++x)]++;
modify(x);
}
for(int i=0;i<n;i++){
printf("%d\n",a[i]);
}
return 0;
}
樹狀數組
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.