title: What is the correct approach to solve SPOJ DIEHARD?
body: <p>I was trying to solve a practice question on SPOJ <a href="https://www.spoj.pl/problems/DIEHARD/" rel="noreferrer">https://www.spoj.pl/problems/DIEHARD/</a> .
  However both my greedy approach resulted in Wrong Answer and recursion was too slow for the worst case.Can anyone tell how to approach this problem? I am looking for someone to point me in the right direction.</p>
  
  <blockquote>
    <p>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.</p>
    
    <ul>
    <li>If you step into air, your health increases by 3 and your armor increases by 2</li>
    <li>If you step into water, your health decreases by 5 and your armor decreases by 10<br>
    If you step into fire, your health decreases by 20 and your armor increases by 5  </li>
    </ul>
    
    <p>If your health or armor becomes &lt;=0, you will die instantly</p>
    
    <p>Find the maximum time you can survive.</p>
    
    <p>Input:</p>
    
    <p>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.</p>
    
    <p>Output:</p>
    
    <p>For each test case find the maximum time you can survive.</p>
  </blockquote>