This is my code for DIEHARD. It is simple enough, and i have optimised it till i can ( i think). I have tried all test cases possible, and all of them are correct (acc. to the comments). Still i am getting Wrong answer.It could'nt be any output format problem acc to me coz we juz have to output a no. per test case and \n which i have. Please HELP!
#include<stdio.h>
int main()
{
int t,time,a,hp;
time=0;
scanf("%d",&t);
while(t--)
{
time=0;
scanf("%d%d",&hp,&a);
while(hp>0 && a>0)
{
hp= hp +3;
a= a+2;
time++;
if(hp<=20 && a<=20)
{
hp=hp-5;
a=a-10;
if(hp>0 && a>0)
{
time++;
}
}
else
if(a>=hp)
{
hp= hp-5;
a=a-10;
time++;
}
else
{
hp=hp-20;
a=a+5;
time++;
}
}
printf("%d\n",time);
}
return 0;
}