3231 Snacks
time limit: 1 sspace limit: 16000 KBtitle level: Golden Gold SolvingView Run ResultsTitle Description
Description
This is a foodie's paradise, too many snacks. Numerous.
Suppose there are n kinds of snacks on the island, each volume VI, the delicacy of WI.
Set a food eater's appetite C, and ask him to eat the greatest delicacy.
Enter a description
Input Description
Two positive integers n C
n a positive integer, Vi
n a positive integer, Wi
Output description
Output Description
Maximum Delicious value
Sample input
Sample Input
4 10
2 5 1 9
10 24 1 100
Sample output
Sample Output
101
Data range and Tips
Data Size & Hint
n<=100,c<=10000,vi,wi<=1000
Can DP, can DFS
#include <cstdio>#include<iostream>#defineM 10010#defineN 110using namespacestd;intF[m],v[n],w[n];intMain () {intM,n; scanf ("%d%d",&n,&m); for(intI=1; i<=n;i++) scanf ("%d",&W[i]); for(intI=1; i<=n;i++) scanf ("%d",&V[i]); for(intI=1; i<=n;i++) for(intj=m;j>=w[i];j--) F[j]=max (f[j],f[j-w[i]]+V[i]); printf ("%d", F[m]); return 0;}
View Code
Snacks (Codevs 3231)