Course Registration codechef problem by java

 

Problem

There is a group of N friends who wish to enroll in a course together. The course has a maximum capacity of M students that can register for it. If there are K other students who have already enrolled in the course, determine if it will still be possible for all the N friends to do so or not.

Input Format

  • The first line contains a single integer T - the number of test cases. Then the test cases follow.
  • Each test case consists of a single line containing three integers NM and K - the size of the friend group, the capacity of the course and the number of students already registered for the course.

Output Format

For each test case, output Yes if it will be possible for all the N friends to register for the course. Otherwise output No.

You may print each character of Yes and No in uppercase or lowercase (for example, yesyEsYES will be considered identical).

Course Registration codechef problem by java

CODE:

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


import java.util.*;

import java.lang.*;

import java.io.*;

import java.util.Scanner;


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

{

Scanner sc = new Scanner(System.in);

        int t = sc.nextInt();

        int result =0;

        for(int i=0; i<t; i++) {

        int n = sc.nextInt();

        int m = sc.nextInt();

        int k = sc.nextInt();

        result = n+k;

        if(result<=m) {

        System.out.println("YES");

        }

        else {

        System.out.println("NO");

        }

       

        }

}

}


Post a Comment

Previous Post Next Post