Question: Please code in java Mr. X in Meeting Mr X is a great competitive programmer. Today, he has to go out to his friends house

Please code in java

Mr. X in Meeting

Mr X is a great competitive programmer. Today, he has to go out to his friends house at 12: 00 p.m for a meeting. It takes him k minutes to reach his friends house. But, he is participating in a contest which will start from 6: 00 a.m. The contest has n problems. He can solve the ith problem of the contest in 3* I minutes. Mr X doesnt want to miss out the meeting, and hence he wants to reach the meeting at the time, but at the same time, he also wants to take part in the contest. Your task is to find out the number of problems Mr X will solve in the contest and at the same time, he reaches the meeting on time, provided he takes k minutes to reach the meeting.

Input FOrmat:

  • The first line of the input consists of a single integer T, denoting the number of test cases.
  • The first line of each test case consists of two integers n, denoting the number of problems in the contest, and k, denoting minutes taken by Mr X to reach his friends house.

Constraints:

1<=T<=100 1<=n<=15 1<=k<=360 

Output Format:

For each test case, Print in a new line the number of problems Mr X can solve in the problem, at the same time, also reaches the meeting on time.

Sample Input:

2 3 319 3 360 

Sample Output:

3 0 

Explanation: In test case 1, Mr X can solve 1st problem in 3 minutes, 2nd in 3*2 = 6 minutes, and 3rd in 3*3 = 9 minutes. So total time he takes in solving problems is 3 + 6 + 9 = 18 minutes. Then, he will take 319 minutes to reach the meeting. This is acceptable, since total time is (18 + 319) minutes = 337 minutes. He would reach the meeting at 11: 37 a.m, which is before 12: 00 p.m. In test case 2, To reach the meeting at 12:00 pm, Mr X needs to leave at 6:00 am the time when the contest starts, thus he would not be able to solve even a single problem.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!