| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:v开[14000]能过 [13000]都过不了.. 为什么In Reply To:v开[14000]能过 [13000]都过不了.. 为什么 Posted by:Viaxl at 2010-01-27 16:57:18 > #include <cstdio>
> #include <cstring>
> #define max(x,y) (x>y?x:y)
>
> int main() {
> int n,V,w[4403],c[4403],v[14000],count_w,from;
>
> ///initialize
> memset(v,0,14000);
> count_w=0;
>
> scanf("%d %d",&n,&V);
> for(int i=1;i<=n;i++) {
> scanf("%d %d",w+i,c+i);
> count_w+=w[i];
> }
>
> from=V-count_w;
>
> for(int i=1;i<=n;i++) {
> from+=w[i];
> for(int j=V;j>=max(w[i],from);j--)
> ///zeroOnePack();
> v[j]=max(v[j],v[j-w[i]]+c[i]);
> }
> printf("%d\n",v[V]);
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator