{"id":"6d99fd7d-c283-4d14-9f96-8f3b7f1ba3d9","name":"Allocate Minimum Number Of Pages","description":"1. You are given N number of books. Every ith book has Ai number of pages. \r\n2. You have to allocate books to M number of students. There can be many ways or permutations to do so. In each permutation, one of the M students will be allocated the maximum number of pages. Out of all these permutations, the task is to find that particular permutation in which the maximum number of pages allocated to a student is minimum of those in all the other permutations and print this minimum value. \r\n3. Each book will be allocated to exactly one student. Each student has to be allocated at least one book.\r\n4. Note: Return -1 if a valid assignment is not possible, and allotment should be in contiguous order.\r\n","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":" 1 &lt;= N &lt;= 10^5\r\n1 &lt;= A [ i ] &lt;= 10^6\r\n1 &lt;= M &lt;= 10^5","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\nbool ispossible(vector<int> &arr,int m,int mid)\n{\n //write your code here\n return false;\n}\nint minimum_pages(vector<int> &arr,int m)\n{\n //write your code here\n return 0;\n}\n\nint main()\n{\n int n;\n cin>>n;\n \n vector<int> arr(n);\n for(int i=0;i<n;i++)\n {\n cin>>arr[i];\n }\n int m;\n cin>>m;\n int x=minimum_pages(arr,m);\n cout<<x;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static int minPages(int[]arr, int m) {\r\n //write your code here\r\n return 0;\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[]arr = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n int m = scn.nextInt();\r\n\r\n int ans = minPages(arr, m);\r\n System.out.println(ans);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"4\r\n12 30 48 10\r\n2","sampleOutput":"58","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":"2f241bb5-0298-4572-b36a-7d43b321b56b","name":"Allocate Minimum Number Of Pages","slug":"allocate-minimum-number-of-pages","type":1}],"next":{"id":"33a5d1f3-8420-47e3-9300-0b836863cb8a","name":"Allocate Minimum Number Of Pages","type":3,"slug":"allocate-minimum-number-of-pages"},"prev":{"id":"dacdc5d3-5955-44c4-a256-c33ca58b1aa1","name":"Chocolate Distribution MCQ","type":0,"slug":"chocolate-distribution-mcq"}}}

Allocate Minimum Number Of Pages

1. You are given N number of books. Every ith book has Ai number of pages. 2. You have to allocate books to M number of students. There can be many ways or permutations to do so. In each permutation, one of the M students will be allocated the maximum number of pages. Out of all these permutations, the task is to find that particular permutation in which the maximum number of pages allocated to a student is minimum of those in all the other permutations and print this minimum value. 3. Each book will be allocated to exactly one student. Each student has to be allocated at least one book. 4. Note: Return -1 if a valid assignment is not possible, and allotment should be in contiguous order.

{"id":"6d99fd7d-c283-4d14-9f96-8f3b7f1ba3d9","name":"Allocate Minimum Number Of Pages","description":"1. You are given N number of books. Every ith book has Ai number of pages. \r\n2. You have to allocate books to M number of students. There can be many ways or permutations to do so. In each permutation, one of the M students will be allocated the maximum number of pages. Out of all these permutations, the task is to find that particular permutation in which the maximum number of pages allocated to a student is minimum of those in all the other permutations and print this minimum value. \r\n3. Each book will be allocated to exactly one student. Each student has to be allocated at least one book.\r\n4. Note: Return -1 if a valid assignment is not possible, and allotment should be in contiguous order.\r\n","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":" 1 &lt;= N &lt;= 10^5\r\n1 &lt;= A [ i ] &lt;= 10^6\r\n1 &lt;= M &lt;= 10^5","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\nbool ispossible(vector<int> &arr,int m,int mid)\n{\n //write your code here\n return false;\n}\nint minimum_pages(vector<int> &arr,int m)\n{\n //write your code here\n return 0;\n}\n\nint main()\n{\n int n;\n cin>>n;\n \n vector<int> arr(n);\n for(int i=0;i<n;i++)\n {\n cin>>arr[i];\n }\n int m;\n cin>>m;\n int x=minimum_pages(arr,m);\n cout<<x;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n\r\n public static int minPages(int[]arr, int m) {\r\n //write your code here\r\n return 0;\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[]arr = new int[n];\r\n\r\n for (int i = 0; i < n; i++) {\r\n arr[i] = scn.nextInt();\r\n }\r\n\r\n int m = scn.nextInt();\r\n\r\n int ans = minPages(arr, m);\r\n System.out.println(ans);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"4\r\n12 30 48 10\r\n2","sampleOutput":"58","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":"2f241bb5-0298-4572-b36a-7d43b321b56b","name":"Allocate Minimum Number Of Pages","slug":"allocate-minimum-number-of-pages","type":1}],"next":{"id":"33a5d1f3-8420-47e3-9300-0b836863cb8a","name":"Allocate Minimum Number Of Pages","type":3,"slug":"allocate-minimum-number-of-pages"},"prev":{"id":"dacdc5d3-5955-44c4-a256-c33ca58b1aa1","name":"Chocolate Distribution MCQ","type":0,"slug":"chocolate-distribution-mcq"}}}
plane

Editor


Loading...

Allocate Minimum Number Of Pages

hard

1. You are given N number of books. Every ith book has Ai number of pages. 2. You have to allocate books to M number of students. There can be many ways or permutations to do so. In each permutation, one of the M students will be allocated the maximum number of pages. Out of all these permutations, the task is to find that particular permutation in which the maximum number of pages allocated to a student is minimum of those in all the other permutations and print this minimum value. 3. Each book will be allocated to exactly one student. Each student has to be allocated at least one book. 4. Note: Return -1 if a valid assignment is not possible, and allotment should be in contiguous order.

Constraints

1 <= N <= 10^5 1 <= A [ i ] <= 10^6 1 <= M <= 10^5

Format

Input

Input is managed for you

Output

Output is managed for you

Example

Sample Input

4 12 30 48 10 2

Sample Output

58

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode