임의의 구간 에서 x 보다 작은 수의 개수 (트 리 배열) 를 구하 십시오.

1218 단어 트 리 배열
제목 변형:http://codeforces.com/contest/811/problem/B
제목: 임의의 구간 에 정렬 하여 x 번 째 위치 에 있 는 수의 위치 에 변화 가 있 는 지 물 어 봅 니 다.
n ^ 2 이 문 제 를 넘 길 수 있다 는 것 을 알 고 내 마음 은 무 너 졌 다.
#include   
#include   
#include   
#include   
using namespace std;  
const int maxn=30005;  
int aa[maxn],bb[maxn];
int C[maxn],ans[maxn];  
int n,m;  
  
int lowbit(int x)  
{  
    return x&(-x);  
}  
  
int sum(int x)  
{  
    int ret=0;  
    while(x>0)  
    {  
        ret+=C[x];  
        x-=lowbit(x);  
    }  
    return ret;  
}  
  
void add(int x,int d)  
{  
    while(x<=n)  
    {  
        C[x]+=d;  
        x+=lowbit(x);  
    }  
}  
  
struct node  
{  
    int id,num;  
    bool operator < (const node &other) const  
    {  
        return num < other.num;  
    }  
}a[maxn];  
struct note  
{  
    int l,r,id,value;  
    bool operator < (const note &other)const  
    {  
        return value 

좋은 웹페이지 즐겨찾기