DCP-338: Again Egg, Banana and Bread Back to All Problems

Medium Divide and Conquer > Dynamic Programming


Many of us prefer to eat egg, banana, and bread as breakfast. **Kauser** has gone to market to bring these items. Problem is that he only has **T** taka in his pocket. He wants to utilize as much his money as possible to bring breakfast such that the amount of Bread he buys should be greater than amount of Banana he buys and the amount of Banana he buys should be greater than amount of Egg he buys. The amount of each of Egg, Banana and Bread must be **at least one**. The price of one egg costs **X** taka, the price of one banana costs **Y** taka and the price of one bread costs **Z** taka. Market price is so much expensive that **you will not get anything else less than 10 taka**. Your task is to help Kauser to utilize as much money as possible and tell him the minimum money he will save in his pocket after buying breakfast. If he can not buy breakfast maintaining above strategy print **-1**. Input: ------ Input starts with an integer **TC (1<=TC<=10)**, denoting the number of test cases. Each case begins with a line containing 3 integers say **X,Y,Z**. Then, there will be next line contains single integer value **T**. Output: ------- For each case of input, output a value as described in the problem statement. Constraints: ------- **10<=X,Y,Z<=100000** **1<=T<=1000000** Sample Input ------------ 1 10 10 10 63 Sample Output ------------- 3


Problem Setter:

Bishal Gautam

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

47/451

Solve/Submission

Ranking

# User Language Timing
01 I_See_You Cpp14 0.00s
02 Optimus_primeV2 Cpp14 0.00s
03 daihan_mbstu Cpp14 0.00s
04 feodorv C 0.01s
05 fsshakkhor Cpp14 0.01s
06 sazal_dev Cpp 0.01s
07 ssavi Cpp14 0.01s
08 Reayz Cpp 0.02s
09 ____ Cpp 0.04s
10 Mahim007 Cpp14 0.05s
11 rayhan50001 Cpp 0.06s
12 ovis96 Cpp14 0.07s
13 kazinayeem Cpp 0.07s
14 asma_chy Cpp14 0.07s
15 pulak_ict_mbstu Cpp14 0.08s
16 Bruteforcekid Cpp 0.08s
17 clkjwdhc Cpp 0.12s
18 Ishrak Cpp 0.13s
19 haasib Cpp 0.13s
20 Morass Cpp14 0.14s
21 njrafi Cpp 0.15s
22 dipta007 Cpp14 0.16s
23 mamun4122 Cpp14 0.16s
24 prateepm Cpp14 0.19s
25 Robbinb1993 Cpp 0.23s
26 sumit1993 Cpp14 0.24s
27 Jisancse Cpp 0.25s
28 Digonta Cpp14 0.29s
29 tariqiitju Cpp 0.32s
30 subhashis_cse Cpp 0.48s
31 alhelal_cse Cpp 0.48s
32 nuhu_iu Cpp 0.48s
33 Rajib_119 Cpp 0.58s
34 ksohan Cpp 0.58s
35 seyedssz Cpp14 0.69s
36 Nirjhor Cpp14 0.82s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support