Shopping, Shopping, Shopping
All submissions for this problem are available.
Shabana, just like any other girl loves to shop. She often visits the Pacific shopping mall to buy new and trendy clothes. With every purchase that she makes, she's awarded with some reward points which she can use to avail some gift.
The gifts offered by the mall includes a bracelet, a necklace, a ring, an anklet and a giant teddy bear, all costing different reward points.
Shabana like to stick to the greedy approach and tends to avail her prize as soon as she has gathered enough reward points. Furthermore, if she has the option to choose between different gifts, she always chooses the most expensive ones. If she's still left with some more reward points she continues to exchange them with gifts.
Now one fine day, Shabana lays all her dresses on her bed and tries to recollect the prizes she got out of the reward points that she earned while buying them.
The first line contains an integer t, the number of test cases to follow.
The first line of each test case contains a number n, i.e the number of dresses she bought.
The second line contains space separated integers representing the reward point earned for each purchases.
The third line contains the cost of 5 gifts in the given order: bracelet, necklace, ring, anklet, teddy bear.
On the first line print 5 space separated integers representing the number of bracelets, necklace, ring, anklet, and teddy bear that she managed to exchange out of the reward points.
In the next line print the remaining reward points.
Should contain all the constraints on the input data that you may have. Format it like:
- 1 ≤ T ≤ 10
- 0 ≤ N ≤ 50
- 1 ≤ Reward Points ≤ 10^5
- 1 ≤ Gifts Cost ( bracelet, necklace, ring, anklet, teddy ) ≤ 10^5
Input: 2 3 3 10 4 2 4 10 15 20 4 10 4 39 2 3 5 10 11 12 Output: 1 1 1 0 0 1 3 0 1 0 3 0
In the first sample Shabana gets 3 points after buying some clothes. Then she exchanges 2 points and gets a bracelet. Shabana gets a bag after shopping for the 2nd time. Then she gets a ring when she shops for the third time. After all the shopping 3 - 2 + 10 - 10 + 4 - 4 = 1 points remains.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.