Solve Me And Get Marks

3.8

4 votes
Problem

"I'm gonna make him an offer he can't refuse".

 

The problem setter loves movies but you want marks , after all you have to pass. Listening to your second year , and not taking any advice from third and fourth year seniors , you cheated in your exam. Now you are worried if you will be caught and run to your problem setter , who is a  third year senior. He tells you not to worry. You should only worry if your paper will go through a plagiarism test.  

 

The good thing about IIITA this year is that there is a strange law about the plagiarism checking. If there are N students in the course , and the score of the ith student is X , then his paper is subjected to plagiarism if and only if there is atleast 1 more student whose score lies in the interval [ X-K , X+K ]  , both included.  

The Profs like to call this number K as NoMercy Value. 

 

Now , you have all the details regarding the above checking. You know N , number of students taking that course , K =  the Mercy value set by the Prof and the marks scored by all N students. 

You want to find how many students should actually take the pressure of getting caught in the plagiarism test and how many student should simply sit back and relax. You also want to print these values with a message as shown in the sample output. 

 

 

INPUT :

The first line has 2 integers N and K  , denoting the number of students in the course  with you and the NoMercy Value chosen by the Proffesor.

The next line contains N integers ,   where ith integer is the marks scored by the ith student in the course. It is guaranteed that all students score non-negative integral marks( highly improbable in Offline semesters ><).

 

OUTPUT :

2 lines should be printed where first and second line should be like

X students need to worry!

Y students should relax!

 

NOTE :  You actually need to print the values of X and Y instead of 'X' and 'Y'.

 

CONSTRAINTS : 

20 Marks :   1 < N < 100  &   K < 100   &    Max. marks scored < 105

20 Marks :   1 < N < 103   &   K < 100  &    Max. marks scored < 105

20 Marks :   1 < N < 105   &   K < 100  &    Max. marks scored < 105

20 Marks :   1 < N < 105   &   K < 105   &   Max. marks  scored < 105

20 Marks :   1 < N < 105   &   K < 105   &   Max. marks  scored < 108

 

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

There are 5 students in the class whose scores are 100 , 9 , 10 , 15 , 1. Now the Professor has set the NoMercy Value as 6.

So , for student 1 with 100 marks there are 0 students whose marks lie in the range  [94,106] other than him. Hence , he should relax.

for student 2 with 9 marks there are 2 more students whose marks lie in the range [3,15]  other than him. Hence , he should worry.

for student 3 with 10 marks there are 2 more students whose marks lie in the range [4,16]  other than him. Hence , he should worry.

for student 4 with 15 marks there are 2 more students whose marks lie in the range [9,21]  other than him. Hence , he should worry.

for student 5 with 1 marks there are 0  students whose marks lie in the range [-5,7]  other than him. Hence , he should relax.

 

Hence , out of the 5 students who gave the exams :

3 students need to worry!

2 students should relax!

Editor Image

?