Punish The Students

easy
1. You are given two arrays rollno and marks where rollno[i] and marks[i] denote the roll number and marks of the ith student. You are also given an integer M.
 2. Mr. Pep conducts an exam for all the students. He had strictly ordered them to sit according to their roll numbers. However when he started checking the papers, he found out that all the papers were randomly ordered. The students had sat randomly during the exam instead of sitting according to their roll numbers. Mr. Pep was very angry and he wanted to teach the students a lesson. He decides to sort the papers by Bubble Sort, count the number of swaps required for each and every student and deduct as many marks of a student as were the number of swaps required for that student. However he also has to maintain a class average of atleast M else he may lose his job. The Mr. Pep wants to know whether he should punish the students or save his job.
 3. Print 1 if he can teach the students a lesson without putting his job at risk, else print 0.
 4. For example, 
 Input: M = 68, rollno = {3,2,4,1,5} and marks = {50,67,89,79,58}
 
 Output: 0
 
 Explanation: 
 Iteration
 
      1           2 3 1 4 5                  -                      Array after 1st iteration
                  1 1 1 1 0                  -                      Number of swaps required for each element
 
      2           2 1 3 4 5                  -                      Array after 2nd iteration
                  1 2 2 1 0                  -                      Number of swaps required for each element
 
      3           1 2 3 4 5                  -                      Array after 3rd iteration
                  3 2 2 1 0                  -                      Number of swaps required for each element
 
 Marks of 1st student = 50 - 3 = 47
 Marks of 2nd student = 67 - 2 = 65
 Marks of 3rd student = 89 - 2 = 87
 Marks of 4th student = 79 - 1 = 78
 Marks of 5th student = 58 - 0 = 58
 
 Class Average = 67 < 68
 Hence, Mr. Pep decides to save his job and output is 0.
 
 Note:
 1. main takes input from the users.
 2. display is a utility function that displays an array. Feel free to use it for debugging purposes.
 3. This is a functional problem.
 4. You have to complete the function punish. It takes as input arrays rollno and marks and M. It should print 1 or 0.

Input Format

First line takes input N and M. Second line takes input N space separated integers representing the elements of the rollno array. Third line takes input N space separated integers representing the elements of the marks array. Input is handled for you.

Output Format

1 or 0. Output is handled for you.

Constraints

N/A

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
5 68
3 2 4 1 5
50 67 89 79 58
Output
0
Previous
Marks Of Pcm
Next
Search In Rotated Sorted Array

Related Questions