Skip to main content

Making friends HackerEarth Question

 Making friends

Max. score: 100

You opened a school with students. Each student will either belong to Team Red or Team Blue. The students in each team are friends with each other. However, you want them to make friends with students from the opposite team too. For example, if a student belongs to Team Red, you want that student to make friends with students from Team Blue.

Note: Friendship is mutual. If A is B's friend, then B is automatically A's friend. 

You give each student a number M that represents the number of friends that the student should have from the opposite team.

Your task is to determine whether it is possible for each student to have the number of friends represented by the number M.

Input format

  • The first line of input is a number T denoting the number of test cases.
  • In each test case:
    • The first line contains a positive integer N denoting the number of students.
    • The second line contains an integer denoting the number of friends that the student should have from the opposite team.

Output format

Print "Yes" or "No" in a new line for each test case based on the possibility that a student can have the number of friends represented by the number M.

Constraints

1<= T <=2*10^5

1 <= N <= 10^5
0 <= M <= 10^5

 

SAMPLE INPUT
 
1
2 1
SAMPLE OUTPUT
 
Yes
Explanation

For example n=2, m=1
There are 2 students in the school, student 1 belonging to Team Red and student 2 belonging to Team Blue, if they become friends then their requirements will be fullfilled as they both require a friend, each. 

Time Limit:5.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB
Marking Scheme:Score is assigned if any testcase passes.
Allowed Languages:Bash, C, C++, C++14, C++17, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, Java 14, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, Python 3.8, Racket, Ruby, Rust, Scala, Swift-4.1, Swift, TypeScript, Visual Basic

Comments

Popular posts from this blog

How to learn Database Management System

 What is DBMS ? DBMS stand for Database Management System and it is a software designed to Define, Manipulate, Retrive, Manage data in a Database. What are the application of DBMS ? It is needed where ever data is stored. Also it is a computerized record keeping system. Example of DBMS :- 1) E-Commerce website like Amazon, Flipkart, Shopcules, eBay, etc.             2) Online Television streaming or OTT Platform like ALT Balaji, Amazon                   Prime,Hotstar, Netflix, MX, etc.             3) It is used in Government Organisation like Bank, University, Police station,              Hospital, Railway, Airline, Human resource Department. 4) Social Media Platform like Whatsapp, Facebook, Instagram, Twitter, Linkedin,      etc.                    THATS ALL FOR TODAY !...

“Maintaining the Work from Home culture among employees for your startup”

  “Maintaining the Work from Home culture among employees for your startup”   While many of us are used to swanky offices in tony districts of our cities and whether we are ready or not, COVID-19 has transitioned many companies to enable remote work at scale. So, how can organizations seize the opportunity and think long-term? Thankfully, most organizations are equipping and have equipped themselves to continue business-as-usual by suddenly shifting gears and adopting work-from-home practices.   But working-from-home comes with its own set of unique challenges—both for the employees and employers. So how to make sure employees are engaged and motivated even when they are away from their traditional work environment? Some of the ways that can maximise the effectiveness of your new Work-From-Home setting: Community Building When employees suddenly start working away from their regular setting, they ar...

Infinix Hot 9 specs leaked

Infinix Hot 9 One of the most awaited smartphone brand Infinix is all set for it's another bid device launch "Infinix Hot 9" series which will be the successor of Infinix hot 8 will be launching soon. It was said on by the officials that it will be launched after 18 days which will be on 17th of april But we are here with it's specs before it's actual launch. Here is the image of it's back panel showing a quad camera in a circular housing featuring 48 MP primary Sensor. The other cameras in the setup could include a wide-angle lens, a macro lens and a depth sensor, going by current trends. The rear of the phone does not feature a fingerprint sensor, suggesting that it may either feature a power button-mounted fingerprint scanner on the side, or an in-display fingerprint sensor. However, given that in-display fingerprint sensors depend on local pixel dimming, and the same is largely possible with OLED-based display panels, it is likelier that...