GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday 27 July 2022

[Solution] Hungry Chef CodeChef Solution 2022



Problem

Chef is very hungry. So, Chef goes to a shop selling burgers. The shop has 2 types of burgers:

  • Normal burgers, which cost X rupees each
  • Premium burgers, which cost Y rupees each (where Y \gt X)

Chef has R rupees. Chef wants to buy exactly N burgers. He also wants to maximize the number of premium burgers he buys. Determine the number of burgers of both types Chef must buy.

Output -1 if it is not possible for Chef to buy N burgers.

Input Format

  • The first line contains a single integer T — the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains four space-separated integers XYN and R — the cost of a

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

  •  normal burger, the cost of a premium burger, the number of burgers Chef wants to buy and the amount of money Chef has.

Output Format

For each test case, output on a new line two integers: the number of normal burgers and the number of premium



 burgers Chef must buy satisfying the given conditions.

Output -1 if he cannot buy N burgers.

Explanation:

Test case 1: Chef has to buy 4 normal burgers only. Even if he buys 1 premium burger, he would not be able to buy 4 burgers.

Test case 2: Chef can buy 8 normal burgers and 2 premium burgers.

Test case 3: It is not possible for Chef to buy 5 burgers.

No comments:

Post a Comment