`{"id":"0a1d999d-050c-40eb-8a05-e73e9056e892","name":"Marks Of Pcm","description":"1. You are provided with marks of N students in Physics, Chemistry and Maths.\r\nPerform the following 3 operations: \r\na). Sort the students in Ascending order of their Physics marks.\r\nb). Once this is done, sort the students having same marks in Physics in the descending order of their Chemistry marks.\r\nc). Once this is also done, sort the students having same marks in Physics and Chemistry in the ascending order of their Maths marks.\r\n2. Your task is to complete the function customSort() which takes phy[], chem[], math[] . The function sorts the marks in the described order and the final changes should be made in the given arrays only.\r\n","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":"1 &lt;= N &lt;= 10000","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\n#include<bits/stdc++.h>\nusing namespace std;\n\nvoid customSort(vector<int> &phy, vector<int> &chem, vector<int> &math){\n \n}\n\nint main(){\n int n;\n cin>>n;\n vector<int> phy(n,0), chem(n,0), math(n,0);\n \n for(int i=0; i<n; ++i){\n cin>>phy[i];\n }\n for(int i=0; i<n; ++i){\n cin>>chem[i];\n }\n for(int i=0; i<n; ++i){\n cin>>math[i];\n }\n \n customSort(phy, chem, math);\n \n for(int i=0; i<n; ++i){\n cout<<phy[i]<<\" \"<<chem[i]<<\" \"<<math[i]<<endl;\n }\n \n return 0;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n /*You have to complete the body of customSort function, \r\n after sorting final changes should be made in given arrays only. */\r\n public static void customSort(int[]phy,int[]chem,int[]math) {\r\n //write your code here\r\n }\r\n\r\n public static void main(String[]args) {\r\n Scanner scn = new Scanner(System.in);\r\n\r\n //input work\r\n int N = scn.nextInt();\r\n\r\n int[]phy = new int[N];\r\n int[]chem = new int[N];\r\n int[]math = new int[N];\r\n\r\n for(int i=0; i < N;i++) {\r\n phy[i] = scn.nextInt();\r\n }\r\n\r\n for(int i=0; i < N;i++) {\r\n chem[i] = scn.nextInt();\r\n }\r\n\r\n for(int i=0; i < N;i++) {\r\n math[i] = scn.nextInt();\r\n }\r\n\r\n customSort(phy,chem,math);\r\n\r\n //output\r\n for(int i=0; i < N;i++) {\r\n System.out.println(phy[i] + \" \" + chem[i] + \" \" + math[i]);\r\n }\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"10\r\n14 1 10 3 4 2 1 10 1 11\r\n5 12 9 6 3 10 2 9 14 10\r\n12 3 6 5 2 10 16 32 10 4","sampleOutput":"1 14 10\r\n1 12 3\r\n1 2 16\r\n2 10 10\r\n3 6 5\r\n4 3 2\r\n10 9 6\r\n10 9 32\r\n11 10 4\r\n14 5 12","questionVideo":"https://www.youtube.com/embed/aGMzcfWsdWE","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":"46d1402c-4b34-4e0c-ad47-4cdba1b65980","name":"Marks Of Pcm","slug":"marks-of-pcm","type":1}],"next":{"id":"d32c4184-5666-4092-851d-3135b60264c6","name":"Marks Of PCM","type":3,"slug":"marks-of-pcm"},"prev":null}}`

# Marks Of Pcm

1. You are provided with marks of N students in Physics, Chemistry and Maths. Perform the following 3 operations: a). Sort the students in Ascending order of their Physics marks. b). Once this is done, sort the students having same marks in Physics in the descending order of their Chemistry marks. c). Once this is also done, sort the students having same marks in Physics and Chemistry in the ascending order of their Maths marks. 2. Your task is to complete the function customSort() which takes phy[], chem[], math[] . The function sorts the marks in the described order and the final changes should be made in the given arrays only.

`{"id":"0a1d999d-050c-40eb-8a05-e73e9056e892","name":"Marks Of Pcm","description":"1. You are provided with marks of N students in Physics, Chemistry and Maths.\r\nPerform the following 3 operations: \r\na). Sort the students in Ascending order of their Physics marks.\r\nb). Once this is done, sort the students having same marks in Physics in the descending order of their Chemistry marks.\r\nc). Once this is also done, sort the students having same marks in Physics and Chemistry in the ascending order of their Maths marks.\r\n2. Your task is to complete the function customSort() which takes phy[], chem[], math[] . The function sorts the marks in the described order and the final changes should be made in the given arrays only.\r\n","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":"1 &lt;= N &lt;= 10000","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<vector>\n#include<bits/stdc++.h>\nusing namespace std;\n\nvoid customSort(vector<int> &phy, vector<int> &chem, vector<int> &math){\n \n}\n\nint main(){\n int n;\n cin>>n;\n vector<int> phy(n,0), chem(n,0), math(n,0);\n \n for(int i=0; i<n; ++i){\n cin>>phy[i];\n }\n for(int i=0; i<n; ++i){\n cin>>chem[i];\n }\n for(int i=0; i<n; ++i){\n cin>>math[i];\n }\n \n customSort(phy, chem, math);\n \n for(int i=0; i<n; ++i){\n cout<<phy[i]<<\" \"<<chem[i]<<\" \"<<math[i]<<endl;\n }\n \n return 0;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n /*You have to complete the body of customSort function, \r\n after sorting final changes should be made in given arrays only. */\r\n public static void customSort(int[]phy,int[]chem,int[]math) {\r\n //write your code here\r\n }\r\n\r\n public static void main(String[]args) {\r\n Scanner scn = new Scanner(System.in);\r\n\r\n //input work\r\n int N = scn.nextInt();\r\n\r\n int[]phy = new int[N];\r\n int[]chem = new int[N];\r\n int[]math = new int[N];\r\n\r\n for(int i=0; i < N;i++) {\r\n phy[i] = scn.nextInt();\r\n }\r\n\r\n for(int i=0; i < N;i++) {\r\n chem[i] = scn.nextInt();\r\n }\r\n\r\n for(int i=0; i < N;i++) {\r\n math[i] = scn.nextInt();\r\n }\r\n\r\n customSort(phy,chem,math);\r\n\r\n //output\r\n for(int i=0; i < N;i++) {\r\n System.out.println(phy[i] + \" \" + chem[i] + \" \" + math[i]);\r\n }\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"10\r\n14 1 10 3 4 2 1 10 1 11\r\n5 12 9 6 3 10 2 9 14 10\r\n12 3 6 5 2 10 16 32 10 4","sampleOutput":"1 14 10\r\n1 12 3\r\n1 2 16\r\n2 10 10\r\n3 6 5\r\n4 3 2\r\n10 9 6\r\n10 9 32\r\n11 10 4\r\n14 5 12","questionVideo":"https://www.youtube.com/embed/aGMzcfWsdWE","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":"46d1402c-4b34-4e0c-ad47-4cdba1b65980","name":"Marks Of Pcm","slug":"marks-of-pcm","type":1}],"next":{"id":"d32c4184-5666-4092-851d-3135b60264c6","name":"Marks Of PCM","type":3,"slug":"marks-of-pcm"},"prev":null}}` Editor

# Marks Of Pcm

medium

1. You are provided with marks of N students in Physics, Chemistry and Maths. Perform the following 3 operations: a). Sort the students in Ascending order of their Physics marks. b). Once this is done, sort the students having same marks in Physics in the descending order of their Chemistry marks. c). Once this is also done, sort the students having same marks in Physics and Chemistry in the ascending order of their Maths marks. 2. Your task is to complete the function customSort() which takes phy[], chem[], math[] . The function sorts the marks in the described order and the final changes should be made in the given arrays only.

1 <= N <= 10000

## Format

### Input

Input is managed for you

### Output

Output is managed for you

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}10 14 1 10 3 4 2 1 10 1 11 5 12 9 6 3 10 2 9 14 10 12 3 6 5 2 10 16 32 10 4```

### Sample Output

```.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}1 14 10 1 12 3 1 2 16 2 10 10 3 6 5 4 3 2 10 9 6 10 9 32 11 10 4 14 5 12```

Question Video

Discussions

Show Discussion

Related Resources 