摘要:
题目限定数的范围N
#include const int N = 100003;
int ind[N];
int data[N];
int vol[N];
int ssize; int lowbit(int x){ return x & (-x);
} void update(int pos, int inc){ while(pos 0){ ret += ind[pos]; pos -= lowbit(pos); } return ret;
} //binarySearch the minimum value x that sum(x) = keyValue(the... 阅读全文
摘要:
/*树状数组求解逆序对(1)对数据进行离散化(2)构建树状数组求解逆序对*/// poj2299逆序对_树状数组.cpp : 定义控制台应用程序的入口点。#include "stdafx.h"#include #include using namespace std;const int N = 500003;typedef struct Node{int value;int no;int tag;}Node;Node node[N], oriNode[N];int n;int sub[N];bool cmp1(Node m1, Node m2){return m1.valu 阅读全文