diff --git a/POJ/2373_sunny606_无优化.cpp b/POJ/2373_sunny606_无优化.cpp new file mode 100644 index 0000000..78c2b2b --- /dev/null +++ b/POJ/2373_sunny606_无优化.cpp @@ -0,0 +1,84 @@ +#include +#include +#define L 1001000 + +int a,b,n,l,inf,dp[L]; +int tree[4*L]; + +void updata(int *p, int rt, int l, int r,int pos, int k) +{ + if (l==r) { + p[rt]=k; + return ; + } + int mid=(l+r)>>1; + if (pos<=mid) updata(p,rt<<1, l, mid, pos, k); + else updata(p, rt<<1|1, mid+1, r, pos, k); + int lv=p[rt<<1]; + int rv=p[rt<<1|1]; + p[rt]=lv>1; + if(e<=mid) return query(p, rt<<1, l, mid, s, e); + if(s>mid) return query(p, rt<<1|1, mid+1, r, s, e); + int lv=query(p,rt<<1, l, mid, s,mid); + int rv=query(p,rt<<1|1, mid+1, r, mid+1, e); + return lv>1); + min = query(tree, 1, 1, l, pos-b, pos-a); + + if (dp[i]<=inf) { + //if(dp[i]>min+1) + dp[i]=min+1; + updata(tree,1,1,l,pos,dp[i]); + /*for(int j=a; j<=b; j++) { + int idx = i-2*j; + if(idx<0) break; + if ( dp[i]>dp[idx]+1 ) dp[i]=dp[idx]+1; + }*/ + } + } + if(dp[l]>=inf) return -1; + else return dp[l]; +} + +int main() +{ + while (scanf("%d%d", &n, &l)!=EOF) { + + scanf("%d%d", &a, &b); + inf = (l/a)+9; + for(int i=0; i<=l; i++) dp[i]=inf; + + for(int i=0; i