# Need Help in question bored in class

int main()
{
long long int t,hhmm,hh,mm,hj;
long long int s,c;
scanf(“%lld”,&t);
while(t–)
{

``````   scanf("%lld",&hhmm);
hj=hhmm;

scanf("%lld",&s);
mm=hhmm%100;
hh=hhmm-mm;
hh=hh/100;

if(s%60==0)
c=s/60;
else
c=s/60+1;

mm=mm+c;
c=mm/60;
mm=mm%60;
hh=hh+c;
if(hh>=24)
{  hh=23;mm=59;}
hhmm=hh*100+mm;
if(hhmm>=hj) {
if(hh<10 || mm<10)
{
if(hh<10)
printf("%d%lld",0,hh);
else
printf("%d",hh);
if(mm<10)
printf("%d%lld\n",0,mm);
else
printf("%lld\n",mm);
}
else
printf("%lld%lld\n",hh,mm);}
else
printf("%lld\n",hj) ;
}
``````

return 0;
}

this is my code for problem CodeChef: Practical coding for everyone
what is wrong can someone help ?

Some edge cases you would want to consider are as follows:

2358

119

Output :2359

2358

120

Output :0000

1201

61

Output :1203

Tell me whether you get the above outputs with your code .

Animesh Fatehpuria

1 Like

Question says maximal time which means maximum value of time displayed on the clock after S seconds.
So sample
2358
120
should have 2359 as maximum time and not 0000.

Am I missing something ?

OK I GOT IT I CONSIDERED 2359 AS THE HIGHEST SO I ASSUMED THAT 2359 IS MAXIMUM NOT 0000. ONLY OUTPUT OF 2358 120 IS INCORRECT REST ALL ARE CORRECT. MY FAULT. ALSO THEN
1
0000
62
WHAT WILL BE OUTPUT OF THIS ?
0001 OR 0000 ?

It was an easy but tricky question. Took me several attempts to figure out the edge case. At First glance it seemed to require a simple greedy algorithm.Hence , The accuracy was pretty low , around 6%.

Can you tell me output of this one
1
0000
62

0002 is the output.

ok thanks a lot i have the same problem hehe if you get the answer please tell me too