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.


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.


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


Sample Input:

2 10
4 4
20 8

Sample Output:


hide comments
ekanshk07: 2021-10-09 11:36:54

[spoiler] is helpful

Last edit: 2021-11-29 19:13:38
gautamgoel96_2: 2021-10-05 11:53:09

doing this problem with [spoiler] is not a good idea , do this question with [spoiler] algorithm
If not able to do then go to stack overflow to see the approach and the code.

Last edit: 2021-11-29 19:13:54
akashnr97: 2021-09-25 20:10:08

[spoiler] problem

Last edit: 2021-11-29 19:14:07
uttaran_das: 2021-09-25 09:17:00

Hint: It doesn't even matter!

yasser1110: 2021-07-25 11:24:22

Did this with [spoiler] + [spoiler] . But this is can be done using simple [spoiler] .

Last edit: 2021-11-29 19:14:20
shubh_ank207: 2021-07-06 08:23:12

done with [spoiler] approach

rupeshtiwari: 2021-07-04 23:44:40

I'm a faggot.

Last edit: 2021-07-05 10:36:17
justcodeforme: 2021-07-01 15:52:27


shr_3: 2021-06-30 08:29:38

solved using [spoiler] with o(1) space.

Last edit: 2021-11-29 19:14:44
sanskar_native: 2021-06-05 20:18:27

does [1001][1001][3] array exceeds the memory available? Gives SIGKILL for me :(

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