C code for this You and your friend are on a treasure hunt and you decided to
Fantastic news! We've Found the answer you've been seeking!
Question:
C code for this
Transcribed Image Text:
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. .... 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. ....
Expert Answer:
Answer rating: 100% (QA)
I have added comments in the C code so that you can understand t... View the full answer
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
Write a C code for this question. Recently Max has got himself into popular CCG "BrainStone". As "BrainStone" is a pretty intellectual game, Max has to solve numerous hard problems during the...
-
Please write a C Code for this problem. Please do not submit C++ or Python Code.
-
C code only for this question please: You learned about priority queues recently and are now ready to solve problems using them! So here's one. Suppose you have an integer array A. For each index i,...
-
The lifespans of gorillas in a particular zoo are normally distributed. The average gorilla lives 20.8 years; the standard deviation is 3.1 years. Use the empirical rule (68 - 95 - 99.7%) to estimate...
-
The increased number of small commuter planes in major airports has heightened concern over air safety. An eastern airport has recorded a monthly average of five near misses on landings and takeoffs...
-
Howard Golub, CFA, is preparing to write a research report on Stellar Energy Corp. common stock. One of the world's largest companies, Stellar is in the business of refining and marketing oil. As...
-
Discuss why AIDS is a reportable disease.
-
On December 1, Diaz Company introduces a new product that includes a one-year warranty on parts. In December, 1,000 units are sold. Management believes that 5% of the units will be defective and that...
-
Martinez Corporation issues $630,000 of 9% bonds, due in 11 years, with interest payable semiannually. At the time of issue, the market rate for such bonds is 10 %. Click here to view factor tables....
-
Costa, Inc., recently converted from a 5-day, 40-hour workweek to a 4-day, 40-hour workweek, with overtime continuing to be paid at one and one-half times the regular hourly rate for all hours worked...
-
Upload an Excel file with the solution of the below problem: During the summer, Olympic swimmer Adam Johnson swims every day. On sunny summer days, he goes to an outdoor pool, where he may swim for...
-
Two cards are drawn in succession from a deck of 52 cards (without replacement). Let \(D_{1}=\{\) diamond is drawn on the first draw\} and \(D_{2}=\) \{diamond is drawn on the second draw\}. Find the...
-
Suppose a person claims to have extrasensory perception (ESP) and says she can read mental images \(75 \%\) of the time. We set up an experiment where she must determine whether we are looking at a...
-
Suppose you are taking a true-false test with ten questions. If you guess at the answers on this test, find the probabilities in Problems 19-22. Exactly eight correct answers
-
What is the probability of obtaining five tails when a coin is flipped five times?
-
Find the probability that a family of eight children has 5 boys and 3 girls.
-
What is ethical blind spot in forensic psychology? What is the blind spot in human behavior?
-
Which of the following is NOT a magnetic dipole when viewed from far away? a) A permanent bar magnet. b) Several circular loops of wire closely stacked together with the same current running in each...
-
You are having lunch at an all-you-can-eat buffet. If you are rational, what should be your marginal utility from the last morsel of food you swallow?
-
The builder of a new movie theater complex is trying to decide how many screens she wants. Below are her estimates of the number of patrons the complex will attract each year, depending on the number...
-
According to the U.S. Census Bureau (www.census.gov), nominal income for the typical family of four in the United States (median income) was $24,332 in 1980, $32,777 in 1985, $41,451 in 1990, and...
-
How many structural isomers are there for hydrocarbons that have the molecular formula C 4 H 10 ? (a) none (b) one (c) two (d) three
-
Which contains more hydrogen atomsa five-carbon saturated hydrocarbon molecule or a five-carbon unsaturated hydrocarbon molecule? (a) The unsaturated hydrocarbon has more hydrogen atoms. (b) The...
-
One solution to the problem of our overflowing landfills is to burn plastic objects instead of burying them. What are some advantages and disadvantages of this practice? (a) disadvantage: toxic air...
Study smarter with the SolutionInn App