{"id":"87e742d4-eb9f-4f4c-b652-21c4f7443fbd","name":"Toppers Of Class","description":"1. There is a class of N students and the task is to find the top K marks scorers. \r\n2. You need to print the index of the toppers of the class which will be same as the index of the student in the input array (use 0-based indexing). \r\n3. First print the index of the students having highest marks then the students with second highest and so on. If there are more than one students having same marks then print their indices in ascending order.Suppose k = 2 and the students having highest marks have indices 0 and 5 and students having second highest marks have indices 6 and 7 then output will be 0 5 6 7.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n","constraints":"1 &lt;= N &lt;= 10^6\r\n1 &lt;= M &lt;= 10^6","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nvoid kToppers(vector<int> &marks, int k, vector<int>& ans){\n //Write your code here\n}\n\nint main(){\n int n;\n cin>>n;\n vector<int> marks(n,0);\n for(int i=0; i<n; i++){\n cin>>marks[i];\n }\n int k;\n cin>>k;\n \n vector<int> ans(k,0);\n kToppers(marks,k, ans);\n \n for(int i=0; i<ans.size(); i++){\n cout<<ans[i]<<\" \";\n }\n}\n"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static int[] kToppers(int[]marks, int k) {\r\n //write your code here\r\n return null;\r\n }\r\n\r\n public static void main(String[]args) {\r\n\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\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 int k = scn.nextInt();\r\n\r\n int[]ans = kToppers(marks, k);\r\n\r\n for (int i = 0; i < ans.length; i++) {\r\n System.out.print(ans[i] + \" \");\r\n }\r\n\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\n2 2 1 3 1\r\n3","sampleOutput":"3 0 1 ","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":"286e3738-fabd-4b5c-bea1-2b69a917085e","name":"Toppers Of Class","slug":"toppers-of-class","type":1}],"next":{"id":"71808d72-fdb1-46a6-9db4-95a4c532062d","name":"Toppers of class","type":3,"slug":"toppers-of-class"},"prev":{"id":"d25daedf-8d6e-48f4-a92d-022e2f54b65c","name":"Ishaan And Sticks MCQ","type":0,"slug":"ishaan-and-sticks-mcq"}}}

Toppers Of Class

1. There is a class of N students and the task is to find the top K marks scorers. 2. You need to print the index of the toppers of the class which will be same as the index of the student in the input array (use 0-based indexing). 3. First print the index of the students having highest marks then the students with second highest and so on. If there are more than one students having same marks then print their indices in ascending order.Suppose k = 2 and the students having highest marks have indices 0 and 5 and students having second highest marks have indices 6 and 7 then output will be 0 5 6 7.

{"id":"87e742d4-eb9f-4f4c-b652-21c4f7443fbd","name":"Toppers Of Class","description":"1. There is a class of N students and the task is to find the top K marks scorers. \r\n2. You need to print the index of the toppers of the class which will be same as the index of the student in the input array (use 0-based indexing). \r\n3. First print the index of the students having highest marks then the students with second highest and so on. If there are more than one students having same marks then print their indices in ascending order.Suppose k = 2 and the students having highest marks have indices 0 and 5 and students having second highest marks have indices 6 and 7 then output will be 0 5 6 7.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n","constraints":"1 &lt;= N &lt;= 10^6\r\n1 &lt;= M &lt;= 10^6","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nvoid kToppers(vector<int> &marks, int k, vector<int>& ans){\n //Write your code here\n}\n\nint main(){\n int n;\n cin>>n;\n vector<int> marks(n,0);\n for(int i=0; i<n; i++){\n cin>>marks[i];\n }\n int k;\n cin>>k;\n \n vector<int> ans(k,0);\n kToppers(marks,k, ans);\n \n for(int i=0; i<ans.size(); i++){\n cout<<ans[i]<<\" \";\n }\n}\n"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static int[] kToppers(int[]marks, int k) {\r\n //write your code here\r\n return null;\r\n }\r\n\r\n public static void main(String[]args) {\r\n\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\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 int k = scn.nextInt();\r\n\r\n int[]ans = kToppers(marks, k);\r\n\r\n for (int i = 0; i < ans.length; i++) {\r\n System.out.print(ans[i] + \" \");\r\n }\r\n\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"5\r\n2 2 1 3 1\r\n3","sampleOutput":"3 0 1 ","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":"286e3738-fabd-4b5c-bea1-2b69a917085e","name":"Toppers Of Class","slug":"toppers-of-class","type":1}],"next":{"id":"71808d72-fdb1-46a6-9db4-95a4c532062d","name":"Toppers of class","type":3,"slug":"toppers-of-class"},"prev":{"id":"d25daedf-8d6e-48f4-a92d-022e2f54b65c","name":"Ishaan And Sticks MCQ","type":0,"slug":"ishaan-and-sticks-mcq"}}}
plane

Editor


Loading...

Toppers Of Class

easy

1. There is a class of N students and the task is to find the top K marks scorers. 2. You need to print the index of the toppers of the class which will be same as the index of the student in the input array (use 0-based indexing). 3. First print the index of the students having highest marks then the students with second highest and so on. If there are more than one students having same marks then print their indices in ascending order.Suppose k = 2 and the students having highest marks have indices 0 and 5 and students having second highest marks have indices 6 and 7 then output will be 0 5 6 7.

Constraints

1 <= N <= 10^6 1 <= M <= 10^6

Format

Input

Input is managed for you

Output

Output is managed for you

Example

Sample Input

5 2 2 1 3 1 3

Sample Output

3 0 1

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode