Snacks (Codevs 3231)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.