Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴代码,思路对了就很简单

Posted by 508618087 at 2011-12-06 23:08:01 on Problem 3624
#include <iostream>
#include <cstring>
#define Max 20000
using namespace std;
int main()
{
    int a[Max],i,j,w,v,M,N,temp;
    cin>>M>>N;
    for(i=1;i<=M;i++)
    {
        cin>>w>>v;
        for(j=N;j>=w;j--)
        {
            temp=a[j-w]+v;              
            if(temp>a[j])
                  a[j]=temp;
        }
    }
    cout<<a[N]<<endl;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator