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
ameyanator: 2018-01-24 18:01:58

lol them spoilers :P

ahaunul_kader: 2018-01-24 16:24:46

How can reduce my time complexity???

ahaunul_kader: 2018-01-24 16:20:14

How can reduce my time complexity???

kmkhan_014: 2017-12-12 10:16:31

chocolate question!!!

anurag31: 2017-11-16 16:16:23

[spoiler] tag is misleading ....actually [spoiler]...yes it can be solved using [spoiler] but no need

Last edit: 2018-01-09 21:06:41
kamrul1157024: 2017-11-15 04:01:42

i don't under stand the test case , Can any one describe it to me ?

madhur4127: 2017-10-25 14:27:07

if you see this comment, then moderator saved it to warn for no spoilers in comments!

algolover: 2017-10-03 17:46:26

what is this *spoiler?

arpit_01: 2017-09-28 18:43:00

why is it showing compilation error, it is working fine on other online ides

nessaa_05: 2017-08-23 07:58:14

easy [spoiler]

Last edit: 2018-01-09 21:07:17

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