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 |
1A,纪念100题。#include<stdio.h> #include<string.h> #define MAXN 12900 int dp[MAXN]; int main() { int n,m,v,w; memset(dp,0,sizeof(dp)); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { scanf("%d%d",&w,&v); for(int j=m;j>=w;j--) { int temp=dp[j-w]+v; if(temp>dp[j]) dp[j]=temp; } } printf("%d\n",dp[m]); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator