二分一个分段数,再用RMQ累加区间最值,跑的好慢哦#include<stdio.h>#include<string.h>const int MAX = 200010;#define min(a,b) a<b?a:b#define max(a,b) a>b?a:bint dp[MAX][30],a[MAX];int k;void init(int n){ memset(dp,0,sizeof(dp)); int i,j,m; for(i=1;i<=n;i++) { dp[i][0]=a[i]; } for(j=1,m=1;m<=n;m<< Read More
posted @ 2011-10-24 18:54 Because Of You Views(727) Comments(0) Diggs(0) Edit
以前的写法太挫了,现在改了一下,精简了View Code #include<stdio.h> #include<string.h> const int MAX = 10010; #define fi(a, b, c) for(int a = (b) ; a < (c) ; a++) #define FI(a, b, c) for(int a = (b) ; a <= (c) ; a++) #define fe(a,b) for(int a=(b); a; a = nxt[a]) int f[MAX],nxt[2*MAX],pnt[2*MAX],h[MAX], Read More
posted @ 2011-10-24 16:37 Because Of You Views(289) Comments(0) Diggs(0) Edit