Answer to Question #325446 in C++ for Anji

Question #325446

coin collection

Rob is fond of collecting coins but unfortunately,sometimes he has to sell a coin to get other coins.he puts all his coins one over the other in a column.

There can be 2 types of Operations:

(0,i):Add coin with value i to the collection.

(1,0):sell a coin.

Selling a coin:

For selling a coin ,he picks up the top coiin in the coloumn if he constraint A is satisfied.Constraint A:Rob can only sell the coin if the coin collection value is more than Y.

Upon emoval ,the coin collection value goes to the previous value.Initially,with 0 coins ,coin collection value is 0.

Adding a Coin:

on addong a coin of value i to the collection the coin collection value increments via the following prodcedure.

If the coin collection had>=X value then current total value is X+i else X+2*i.

Rob needs to find and return the final value of coin collection after Q operations.

Note : Initially,the value X is 0 and not X.

Example1:

input1:10

input2:0

input3:1

input4:{{0,5}}

output:10


0
Service report
It's been a while since this question is posted here. Still, the answer hasn't been got. Consider converting this question to a fully qualified assignment, and we will try to assist. Please click the link below to proceed: Submit order

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS