第一道树状数组,每个第一道都那么艰难……..
#include#include #include using namespace std;#define MAX 1234567890int res[10010],data[10010];int lowbite(int x){ return x & (x^(x-1));}int GetSum(int i){ int t=0; while(i>0) { t+=res[i]; i-=lowbite(i); } return t;}int Add(int i,int n){ while(i<=n) { res[i]++; i+=lowbite(i); } return 0;}int main(){ int i,j,m,n,max,k,sum; while(scanf("%d %d",&n,&m)!=EOF) { max=-1; for(i=0;i max) {max=sum; k=i+1;} } printf("%d\n",k); } return 0;}