Game of Possibility Solution

 

Problem

In the games played so far in the tournament, your team has earned P points. To qualify for the semi-finals, you must collect a total of at least Q points. You currently have R games remaining in which you can earn 2 points for a victory, 1 points for a tie, and no points for a loss.

Is it possible that your team will make it to the semi-finals?

Input Format

  • The first line will have the value T, which represents the number of testcases. Then come the testcases.
  • Each testcase has a single line of input and three numbers P, Q, R.

Output Format

For each test case, output in a single line YES if your team can qualify for the semi-finals, or NO if not possible.

Because output is case insensitive, "yes", "Yes", "YEs", "no", "nO" - all such strings will be accepted.

Constraints

  • 1 \leq T \leq 5000
  • 0 \leq P,Q,R \leq 1000

Sample 1:

Input
Output
3
4 10 8
3 6 1 
4 8 2 
YES
NO
YES

Explanation:

Test Case 1: There are still 8 games available. If you win 2 games, lose 4 games, and draw the remaining 2 games, you will have a total of 10 points, demonstrating that it is achievable.

Test Case 2: There is no way that you can qualify for the semi-finals.

Test Case 3: You will have 8 points if you win all of the remaining games. As a result, qualifying for the semi-finals is possible (4 + 2*2 = 8).






Program :


/* 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

{

// your code goes here

int p,q,r,t,a;

        Scanner sc=new Scanner(System.in);

        t=sc.nextInt();

        while(t-->0){

            p=sc.nextInt();

            q=sc.nextInt();

            r=sc.nextInt();

            a=r*2;

            if(p+a>=q)

                System.out.println("YES");

            else

                System.out.println("NO");

        }

}

}

Post a Comment

0 Comments