DIEHARD - DIE HARD

Problem Statement:

The game is simple. You initially have ‘H’ amount of health and ‘A’ amount of armor. At any instant you can live in any of the three places - fire, water and air. After every unit time, you have to change your place of living. For example if you are currently living at fire, you can either step into water or air.

If you step into air, your health increases by 3 and your armor increases by 2

If you step into water, your health decreases by 5 and your armor decreases by 10

If you step into fire, your health decreases by 20 and your armor increases by 5

If your health or armor becomes <=0, you will die instantly

Find the maximum time you can survive.

Input:

The first line consists of an integer t, the number of test cases. For each test case there will be two positive integers representing the initial health H and initial armor A.


Output:

For each test case find the maximum time you can survive.

 

Note: You can choose any of the 3 places during your first move.

 

Input Constraints:

1 <= t <= 10
1 <= H, A <= 1000

Example:

Sample Input:

3
2 10
4 4
20 8

Sample Output:

1
1
5

Added by:cegprakash
Date:2012-10-13
Time limit:10s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2017-06-03 12:21:32
small mistake using [spoiler] costed me a TLE...


Last edit: 2017-08-02 12:54:25
2017-05-20 06:17:56 Nafis Islam
ac in one go :D
2017-05-15 19:07:07
Is there any problem with test case 5? I am continuously getting WA.
2017-05-07 05:49:26
because it can be done using [spoiler]. Also, u get saved from proving the correctness of ur [spoiler] solution

Last edit: 2017-08-02 12:54:47
2017-04-06 13:21:21 pbd
extremely easy [spoiler] problem. why is it [spoiler]?

Last edit: 2017-08-02 12:55:13
2017-03-13 15:32:47
Spent 2 days trying to come up with a better idea because I thought my initial idea would get TLE but it got accepted at 0.02 sec wtf.
2017-03-13 01:09:54
My 50th!!!
Very suitable name for the problem. [spoiler] broke my brain.

Last edit: 2017-08-02 12:55:56
2017-03-05 12:56:44
Typo caused WA!!
Easy [spoiler]!

Last edit: 2017-03-08 09:15:37
2017-03-03 18:30:12
taking cases also works
2017-02-26 22:25:41
AC in a go! simple but thoughtful..
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.