NFS - Editorial

Thanks a lot, i had assumed u^2-2as would be always be +ve as v<u, made such a horrible silly mistake.

Thank you! I really didn’t thought about this case.

Even using BufferReader also it can’t be solved under the time limit as there is no way in java no one can solve it under the time limit of 0.5 sec

well i think the time limit which is given there is general, it varies language to language.

Below solution is accepted in 0.52 Seconds.

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
        int t = Integer.parseInt(inp.readLine());
        while (t-- > 0) {
            String[] uvas = inp.readLine().split(" ");
            int u = Integer.parseInt(uvas[0]);
            int v = Integer.parseInt(uvas[1]);
            int a = Integer.parseInt(uvas[2]);
            int s = Integer.parseInt(uvas[3]);
            double vel = Math.sqrt(Math.pow(u, 2) - (2 * a * s));
            if (Math.pow(u, 2) - (2 * a * s) < 1) {
                out.write("YES\n");
            } else if (vel <= (double) v) {
                out.write("YES\n");
            } else {
                out.write("NO\n");
            }
            out.flush();
        } 
	}
}