
Jumbo Burger: 4 tomato slices and 1 cheese slice.
Small Burger: 2 Tomato slices and 1 cheese slice.
Given:-
‘TOMATO_SLICES’ = 6 and ‘CHEESE_SLICES’ = 2.
Therefore 1 Jumbo Burger and 1 Small Burger can be formed using the available slice completely.
Hence the answer is [1, 1].
The first line of input contains an integer T denoting the number of test cases.
The next ‘T’ lines contain exactly 2 space-separated integers, ‘TOMATO_SLICES’ and ‘CHEESE_SLICES’, which represent the number of tomato slices and cheese slices available respectively.
For each test case, print an integer denoting the total number of burgers of each type that can be formed.
The output of each test case will be printed in a separate line.
You don't have to print anything, it has already been taken care of. Just implement the given function.
If the number of ‘CHEESE_SLICES’ or ‘TOMATO_SLICES’ can’t be made 0, then return [-1, -1]
1 <= T <= 10
0 <= CHEESE_SLICES,TOMATO_SLICES <= 10 ^ 8
Time limit: 1 sec
The main idea is to loop from 1 to the number of ‘CHEESE_SLICES’ we have and for each, calculate if, for the given number of ‘CHEESE_SLICES’, if we can make ‘SMALL_BURGERS’, can we use the rest of the ‘TOMOATO_SLICES’ in the ‘JUMBO_BURGERS’.
The main idea is to form 2 linear equations, such that we can find the values of ‘JUMBO_BURGER’ and ‘SMALL_BURGER’ by substituting from one equation to another.