Answered step by step
Verified Expert Solution
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++
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 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started