Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Passes for Fair CodeChef Solution

Problem – Passes for Fair CodeChef Solution

There is a fair going on in Chefland. Chef wants to visit the fair along with his N friends. Chef manages to collect K passes for the fair. Will Chef be able to enter the fair with all his N friends?

A person can enter the fair using one pass, and each pass can be used by only one person.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of a single line containing two space-separated integers N,K.

Output Format

For each test case, print on a new line YES if Chef will be able to enter the fair with all his N friends and NO otherwise.

You may print each character of the string in either uppercase or lowercase (for example, the strings yEsyesYes, and YES will all be treated as identical).

Constraints

  • 1 \leq T \leq 1001≤T≤100
  • 1 \leq N, K \leq 1001≤N,K≤100

Sample 1:

Input: 4
5 8
6 3
2 2
1 2
Output: YES
NO
NO
YES

Explanation:

Test case 1: Chef needs 5 passes for his friends and one pass for himself and he collected 8 passes. Thus he will be able to enter the fair with all his friends.

Test case 2: Chef needs 6 passes for his friends and one pass for himself while he collected only 3 passes. Thus he will not be able to enter the fair with all his friends, only three of them can enter the fair.

Test case 3: Chef needs 2 passes for his friends and one pass for himself while he collected only 2 passes. Thus either Chef or one of his friends can’t enter the fair.

Test case 4: Chef needs a total of 2 passes, one for himself and one for his friend. He collected 2 passes. Thus he will be able to enter the fair with his friend.

Passes for Fair CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--)
	{
	    int n,k;
	    cin>>n>>k;
	    if(k>=n+1)
	    cout<<"YES"<<endl;
	    else
	    cout<<"NO"<<endl;
	}
	return 0;
}

Passes for Fair CodeChef Solution in Java

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

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int t= sc.nextInt();
		for (int i=0;i<t;i++){
		    int n = sc.nextInt();
		    int k = sc.nextInt();
		    if(k>n){
		        System.out.println("yes");
		    }
		    else{
		        System.out.println("no");
		    }
		} 
	
  	}
}

Passes for Fair CodeChef Solution in Python3

for i in range(int(input())):
    a,b=map(int,input().split(" "))
    if a+1<=b:
        print("YES")
    else:
        print("NO")
Passes for Fair CodeChef Solution Review:

In our experience, we suggest you solve this Passes for Fair CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Passes for Fair CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Passes for Fair CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *