Question: 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

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

1 Expert Approved Answer
Step: 1 Unlock

I have added comments in the C code so that you can understand t... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!