Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ The Christmas season is not anymore the time for Santa Claus to deliver gifts to every person on the earth. He now wants to

C++

image text in transcribed

The Christmas season is not anymore the time for Santa Claus to deliver gifts to every person on the earth. He now wants to take things away from people. When he enters Gigel's house, he finds N objects, and each object may weigh up to 1000 grams. Santa Claus needs to know if there is a subset of objects in Gigel's house whose combined weight is equal to W because he can only carry a maximum of W grams in his backpack. Help Santa know whether he can steal objects from the following M houses, knowing that his backpack's maximum weight changes at each house he visits. Data format Input The input file is called "santa. in". The first line contains the number of houses M. The second line contains the number of objects N from the first house, followed by the maximum weight of the backpack W available for the first house. Each of the next N lines contains one integer Gi, which represents the weight of the object i, that Santa finds in the first house. Output The output file is called "santa ouf". It contains only one line with the word "yes", if exists a subset of objects whose combined weight is equal to W, or "no" if there is no such subset of objects Data limits 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

ISBN: 0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

2. What efforts are countries making to reverse the brain drain?

Answered: 1 week ago