{"id":"9621d513-3f9b-4b13-a900-b862e12233ff","name":"Punish The Students","description":"1. A Professor conducts a Computer Science paper for N students. He had strictly instructed all students to sit according to their roll numbers. However when he started checking the papers, he found out that all the papers were randomly ordered because the students had sat randomly during the exam instead of sitting according to their roll numbers. The order is given in list of integers roll[ ]. The professor became very angry and he wanted to teach the students a lesson.\r\n2. He decided to sort the papers according to roll numbers by Bubble Sort and 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. The marks of every student is given in list of integers marks[ ] in the order in which they were sitting. However he also has to maintain the class average greater than or equal to a set minimum avg, else he may lose his job. \r\n3. The Professor wants to know whether he should punish the students or save his job.\r\n","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":" 1 &lt;= N &lt;= 1000","sampleCode":{"cpp":{"code":"#include <iostream>\n#include <vector>\nusing namespace std;\n\nbool shouldPunish(vector<int> &roll, vector<int> &marks, double avg) {\n //write your code here \n return true;\n}\n\nint main() {\n //input work\n int n = 0;\n cin>>n;\n vector<int> roll(n);\n \n for (int i = 0; i < n; i++) {\n cin>>roll[i];\n }\n \n vector<int> marks(n);\n \n for (int i = 0; i < n; i++) {\n cin>>marks[i];\n }\n \n double avg = 0;\n cin>>avg;\n if(shouldPunish(roll, marks, avg))\n cout<<\"true\";\n else\n cout<<\"false\";\n \n return 0;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static boolean shouldPunish(int[]roll, int[]marks, double avg) {\r\n //write your code here\r\n }\r\n\r\n public static void main(String[]args) {\r\n //input work\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n\r\n int[]roll = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n roll[i] = scn.nextInt();\r\n }\r\n\r\n int[]marks = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n marks[i] = scn.nextInt();\r\n }\r\n\r\n double avg = scn.nextDouble();\r\n\r\n System.out.println(shouldPunish(roll, marks, avg));\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\n3 2 4 1 5\r\n50 67 89 79 58\r\n68","sampleOutput":"false","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"d4256253-2345-47cb-bd6c-caa61366f36b","name":"Punish The Students","slug":"punish-the-students","type":1}],"next":{"id":"27bc078a-09e9-4249-a576-b42a543a534f","name":"Punish The Students","type":3,"slug":"punish-the-students"},"prev":{"id":"00a49079-ac26-4693-9d3f-70d8bb471db5","name":"Heaters MCQ","type":0,"slug":"heaters-mcq"}}}

Punish The Students

1. A Professor conducts a Computer Science paper for N students. He had strictly instructed all students to sit according to their roll numbers. However when he started checking the papers, he found out that all the papers were randomly ordered because the students had sat randomly during the exam instead of sitting according to their roll numbers. The order is given in list of integers roll[ ]. The professor became very angry and he wanted to teach the students a lesson. 2. He decided to sort the papers according to roll numbers by Bubble Sort and 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. The marks of every student is given in list of integers marks[ ] in the order in which they were sitting. However he also has to maintain the class average greater than or equal to a set minimum avg, else he may lose his job. 3. The Professor wants to know whether he should punish the students or save his job.

{"id":"9621d513-3f9b-4b13-a900-b862e12233ff","name":"Punish The Students","description":"1. A Professor conducts a Computer Science paper for N students. He had strictly instructed all students to sit according to their roll numbers. However when he started checking the papers, he found out that all the papers were randomly ordered because the students had sat randomly during the exam instead of sitting according to their roll numbers. The order is given in list of integers roll[ ]. The professor became very angry and he wanted to teach the students a lesson.\r\n2. He decided to sort the papers according to roll numbers by Bubble Sort and 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. The marks of every student is given in list of integers marks[ ] in the order in which they were sitting. However he also has to maintain the class average greater than or equal to a set minimum avg, else he may lose his job. \r\n3. The Professor wants to know whether he should punish the students or save his job.\r\n","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":" 1 &lt;= N &lt;= 1000","sampleCode":{"cpp":{"code":"#include <iostream>\n#include <vector>\nusing namespace std;\n\nbool shouldPunish(vector<int> &roll, vector<int> &marks, double avg) {\n //write your code here \n return true;\n}\n\nint main() {\n //input work\n int n = 0;\n cin>>n;\n vector<int> roll(n);\n \n for (int i = 0; i < n; i++) {\n cin>>roll[i];\n }\n \n vector<int> marks(n);\n \n for (int i = 0; i < n; i++) {\n cin>>marks[i];\n }\n \n double avg = 0;\n cin>>avg;\n if(shouldPunish(roll, marks, avg))\n cout<<\"true\";\n else\n cout<<\"false\";\n \n return 0;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static boolean shouldPunish(int[]roll, int[]marks, double avg) {\r\n //write your code here\r\n }\r\n\r\n public static void main(String[]args) {\r\n //input work\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n\r\n int[]roll = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n roll[i] = scn.nextInt();\r\n }\r\n\r\n int[]marks = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n marks[i] = scn.nextInt();\r\n }\r\n\r\n double avg = scn.nextDouble();\r\n\r\n System.out.println(shouldPunish(roll, marks, avg));\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\n3 2 4 1 5\r\n50 67 89 79 58\r\n68","sampleOutput":"false","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"cb36811c-9cd7-4d80-aa52-ae9b8409862a","name":"Searching And Sorting For Intermediate","slug":"searching-and-sorting-for-intermediate-10001","type":0},{"id":"d4256253-2345-47cb-bd6c-caa61366f36b","name":"Punish The Students","slug":"punish-the-students","type":1}],"next":{"id":"27bc078a-09e9-4249-a576-b42a543a534f","name":"Punish The Students","type":3,"slug":"punish-the-students"},"prev":{"id":"00a49079-ac26-4693-9d3f-70d8bb471db5","name":"Heaters MCQ","type":0,"slug":"heaters-mcq"}}}
plane

Editor


Loading...

Punish The Students

easy

1. A Professor conducts a Computer Science paper for N students. He had strictly instructed all students to sit according to their roll numbers. However when he started checking the papers, he found out that all the papers were randomly ordered because the students had sat randomly during the exam instead of sitting according to their roll numbers. The order is given in list of integers roll[ ]. The professor became very angry and he wanted to teach the students a lesson. 2. He decided to sort the papers according to roll numbers by Bubble Sort and 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. The marks of every student is given in list of integers marks[ ] in the order in which they were sitting. However he also has to maintain the class average greater than or equal to a set minimum avg, else he may lose his job. 3. The Professor wants to know whether he should punish the students or save his job.

Constraints

1 <= N <= 1000

Format

Input

Input is managed for you

Output

Output is managed for you

Example

Sample Input

5 3 2 4 1 5 50 67 89 79 58 68

Sample Output

false

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode