Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C code for this You and your friend are on a treasure hunt and you decided to split your search. After some systematic searching based

C code for this 

You and your friend are on a treasure hunt and you decided to split your search. After some systematic searching based on techniques you've learned in ES242, you find a box of gold coins! The coins have values a1, a2, .. , An, You text your location to your friend and are waiting for her to come back so you can call it a day. Now for the twist: while you are waiting, you think: "Why split the money equally?". After all, your friend is on her way and she won't know anything. So you decided to act like that: pick for yourself some subset of coins so that the sum of values of your coins is strictly larger than the sum of values of the remaining coins that your friend will have. However, you correctly thought that if you take too many coins, your friend will suspect the deception. So, you've decided to stick to the following strategy to avoid suspicions: you take the minimum number of coins, whose sum of values is strictly more than the sum of values of the remaining coins. On this basis, determine what minimum number of coins you need to take to divide them in the described manner? Input The first line contains integer n (1 sns 100) the number of coins. The second line contains a sequence of nintegers a1, az, ., an (1 saj 100) the coins' values. All numbers are separated with spaces. ....

Step by Step Solution

3.29 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

I have added comments in the C code so that you can understand t... 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

Principles of Economics

Authors: Robert Frank, Ben Bernanke

5th edition

73511404, 978-0073511405

More Books

Students also viewed these Algorithms questions