The Dangerous Hideout
All submissions for this problem are available.
Alibaba is chasing the Captain of the Thieves through the magic realm of Persia! The Captain has taken refuge in a dangerous area where Alibaba can't follow. So, he waits for him to come out of hiding.
The captain initially has H amount of health and A amount of armour. The hiding place has 3 areas, Fire, Air and Water. At any instant, he can live in any of the 3 places - fire, water and air. After every unit time, he has to change his place of living.
- If he is currently living at fire, he can either step into water or air.
- If he steps into air, his health increases by 3 and his armour increases by 2.
- If he steps into water, his health decreases by 5 and his armour decreases by 10.
- If he steps into fire, his health decreases by 20 and his armour increases by 5.
- If his health or armour becomes <=0, he will die instantly.
Alibaba wants to find out the maximum time the Captain can survive in the hideout.
The first line consists of an integer t, the number of test cases.
For each test case there will be 2 positive integers representing the initial health H and initial armor A.
For each test case, find the maximum time the Captain of the Thieves can survive.
NOTE: He can choose any of the 3 places during his first move.
Sample Input: 3 2 10 4 4 20 8
1 1 5
|Time Limit:||0.5 sec|
|Source Limit:||50000 Bytes|
|Languages:||CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.