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
hide comments
anandsaurabh46:
2021-05-06 20:55:05
[Spoiler] solution is very easy, Works in O(Spoiler) in worst case.
|
|
vaibhav_2802:
2021-05-04 11:23:10
It's much easier with [spoiler] approach Last edit: 2021-06-18 17:45:33 |
|
patty1121:
2021-04-27 09:39:23
[spoiler] works fine
|
|
vasutiwari17:
2021-04-08 11:53:26
can this be solved with [spoiler] ??? Last edit: 2021-06-18 17:43:40 |
|
vishal_311:
2021-03-12 22:02:07
what is the 5th test case?
|
|
reaped_juggler:
2021-03-12 06:58:12
AC in 2nd go, [spoiler][spoiler] is love :3 |
|
chetan06:
2021-03-03 06:06:16
any test case?
|
|
sakshi_38:
2021-03-01 13:40:12
what is spolier here ?? everyone is talking about this !!! |
|
alpha_power:
2021-01-27 18:08:05
Easy with recursion. |
|
loser_404:
2021-01-15 15:40:26
I'm a loser indeed Last edit: 2021-01-15 15:55:13 |
Added by: | cegprakash |
Date: | 2012-10-13 |
Time limit: | 10s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |