Medium Beginners Problems > Ad-hoc

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 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 containg single integer value **T**. Output: ------- For each case of input, output a value as described in the problem statement. Constraints: ------- **10<=X,Y,Z<=1000** **1<=T<=1000** Sample Input ------------ 1 65 95 51 900 Sample Output ------------- 3

Bishal Gautam

Language |
Time Limit (seconds) |

C | 0.50 |

C++ | 0.50 |

C++14 | 0.50 |

C# | 1.00 |

Go | 1.00 |

Java | 1.00 |

JavaScript | 1.00 |

Objective-C | 1.00 |

Perl | 1.00 |

PHP | 1.00 |

Python | 1.00 |

Python3 | 1.00 |

Ruby | 1.00 |

VB.Net | 1.00 |

Solve/Submission

# | User | Language | Timing |
---|---|---|---|

01 | Dark_Ocean | Cpp14 | 0.00s |

02 | badhansen123 | Cpp14 | 0.00s |

03 | subhashis_cse | Cpp | 0.00s |

04 | haasib | Cpp14 | 0.00s |

05 | zyyxxx | Cpp14 | 0.00s |

06 | Optimus_primeV2 | Cpp14 | 0.00s |

07 | Jisancse | Cpp | 0.00s |

08 | njrafi | Cpp14 | 0.00s |

09 | ifat_just | Cpp14 | 0.00s |

10 | priojeet_priyom | Cpp14 | 0.00s |

11 | shamimjucse | Cpp14 | 0.00s |

12 | Masum_ice | Cpp14 | 0.00s |

13 | Pure_Protea | Cpp14 | 0.00s |

14 | saiful130104 | Cpp14 | 0.00s |

15 | MRITuhin | Cpp14 | 0.00s |

16 | tariqiitju | Cpp14 | 0.00s |

17 | rayhan50001 | Cpp14 | 0.00s |

18 | SbrTa | Cpp14 | 0.00s |

19 | Brokenlog | Cpp14 | 0.00s |

20 | pulak_ict_mbstu | Cpp14 | 0.00s |

21 | Sarwar05 | Cpp | 0.00s |

22 | faceless_void | Cpp14 | 0.00s |

23 | feodorv | Cpp14 | 0.00s |

24 | anik_JU | Cpp14 | 0.00s |

25 | AlaminJust | Cpp14 | 0.00s |

26 | Chayti_Saha98 | Cpp14 | 0.00s |

27 | drifter | Cpp | 0.00s |

28 | nurshuvo51 | Cpp14 | 0.00s |

29 | Rajan_sust | Cpp14 | 0.00s |

30 | ovis96 | Cpp14 | 0.00s |

31 | Ishraq_Nibir | Cpp14 | 0.00s |

32 | hrOarr | Cpp14 | 0.00s |

33 | SakibAlamin | Cpp14 | 0.00s |

34 | ____ | Cpp14 | 0.00s |

35 | kissu_pari_na | Cpp14 | 0.00s |

36 | Islam_Rafat | Cpp14 | 0.00s |

37 | ZERO | Cpp14 | 0.00s |

38 | _c_k_r_ | Cpp14 | 0.00s |

39 | Bruteforcekid | Cpp | 0.00s |

40 | KAMO1 | Cpp14 | 0.00s |

41 | daihan_mbstu | Cpp14 | 0.00s |

42 | Morass | Cpp14 | 0.00s |

43 | rajdipsaha | Cpp | 0.01s |

44 | mh755628 | Cpp14 | 0.01s |

45 | _dipu | Cpp14 | 0.01s |

46 | alif_biswas | Cpp14 | 0.01s |

47 | nahid08 | Cpp14 | 0.01s |

48 | a_rahman | Cpp14 | 0.01s |

49 | nazmul49 | Cpp14 | 0.01s |

50 | sazal_dev | Cpp14 | 0.01s |

Copyright © 2015-2016 Dev Skill.

Feedback
#### Your feedback is our precious!

## Thank you for providing feedback! Our developers will be happy :)

## Sorry there was a problem when submitting the feedback. Please try again. :(