import java.util.*;
class Bank
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
float a=sc.nextFloat();
float b=sc.nextFloat();
if(((a%5)==0))
{
if(a<=b-0.5)
{
b=b-(float)0.50;
b=b-a;
System.out.printf(".2f",b);
}
else
{
System.out.printf(".2f",b);
}
}
else
{
System.out.printf("%.2f",b);
}
}
}
Since the solution is O(1) time , so you can use faster input/output methods like BufferedReader or you can also write your own input/output methods.
P.S. Please don’t compare the time taken by C/C++ codes and JAVA codes. JAVA is approx. 2 times slower than C/C++. So, the time limit of problems is different for different programming languages.
2 Likes
TAKE A LOOK AT MY CODE: http://www.codechef.com/viewsolution/6409235
IT IS TAKING 0.11 SECS