|
|
back to boardI don't understand Im getting TLE on test 3 Posted by alkaid 30 Jun 2011 02:15 I'm using BIT this is my c++ solution #include <stdio.h> #define mxn 15005 #define mxm 32005 int l[mxn]; int b[mxm]; int n; int get(int x) { int s = 0; while(x > 0) { s += b[x]; x -= (x & -x); } return s; } void add(int x) { while(x < mxm) { b[x]++; x += (x & -x); } } int main() { scanf("%d",&n); for(int i = 0; i < n; i++) { int a,b; a++; scanf("%d%d",&a,&b); l[get(a)]++; add(a); }
for(int i = 0; i < n; i++) printf("%d\n",l[i]); } Re: I don't understand Im getting TLE on test 3 Posted by alkaid 30 Jun 2011 02:17 sorry, hehe, but position to my "a++" |
|
|