{"id":"c4c13c6c-1215-470e-8d85-c9e3297de89f","name":"Find The Smallest Divisor Given A Threshold","description":"1. Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned above is less than or equal to threshold.\r\n2. Each result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).\r\n3. It is guaranteed that there will be an answer.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n ","constraints":"1 &lt;= nums.length &lt;= 5 * 10^4\r\n1 &lt;= nums[i] &lt;= 10^6\r\nnums.length &lt;= threshold &lt;= 10^6","sampleCode":{"cpp":{"code":"#include <iostream>\n#include <cmath>\n#include <algorithm>\n#include <vector>\nusing namespace std;\n\nint findSmallestDivisor(vector<int> &nums,int th) {\n //write your code here\n return 0;\n}\n\nint main() {\n int n = 0;\n cin>>n;\n vector<int> nums(n);\n\n for(int i=0 ; i < n ; i++) {\n cin>>nums[i];\n }\n\n int th = 0;\n cin>>th;\n int div = findSmallestDivisor(nums,th);\n cout<<div;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n public static int findSmallestDivisor(int[]nums,int th) {\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 //input work\r\n int n = scn.nextInt();\r\n int[]nums = new int[n];\r\n\r\n for(int i=0 ; i < n ; i++) {\r\n nums[i] = scn.nextInt();\r\n }\r\n\r\n int th = scn.nextInt();\r\n\r\n int speed = findSmallestDivisor(nums,th);\r\n System.out.println(speed);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"4\r\n1 2 5 9\r\n6","sampleOutput":"5","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":"da246144-e404-4107-b846-327a46427586","name":"Find The Smallest Divisor Given A Threshold","slug":"find-the-smallest-divisor-given-a-threshold","type":1}],"next":{"id":"e11863db-f2d3-4baf-87cd-796af9631b8e","name":"Find The Smallest Divisor Given A Threshold","type":3,"slug":"find-the-smallest-divisor-given-a-threshold"},"prev":{"id":"8445462b-c40a-49a5-ba16-b3c32921aaec","name":"Koko Eating Bananas MCQ","type":0,"slug":"koko-eating-bananas-mcq"}}}

Find The Smallest Divisor Given A Threshold

1. Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned above is less than or equal to threshold. 2. Each result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5). 3. It is guaranteed that there will be an answer.

{"id":"c4c13c6c-1215-470e-8d85-c9e3297de89f","name":"Find The Smallest Divisor Given A Threshold","description":"1. Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned above is less than or equal to threshold.\r\n2. Each result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5).\r\n3. It is guaranteed that there will be an answer.\r\n","inputFormat":"Input is managed for you\r\n","outputFormat":"Output is managed for you\r\n ","constraints":"1 &lt;= nums.length &lt;= 5 * 10^4\r\n1 &lt;= nums[i] &lt;= 10^6\r\nnums.length &lt;= threshold &lt;= 10^6","sampleCode":{"cpp":{"code":"#include <iostream>\n#include <cmath>\n#include <algorithm>\n#include <vector>\nusing namespace std;\n\nint findSmallestDivisor(vector<int> &nums,int th) {\n //write your code here\n return 0;\n}\n\nint main() {\n int n = 0;\n cin>>n;\n vector<int> nums(n);\n\n for(int i=0 ; i < n ; i++) {\n cin>>nums[i];\n }\n\n int th = 0;\n cin>>th;\n int div = findSmallestDivisor(nums,th);\n cout<<div;\n}"},"java":{"code":"import java.util.*;\r\nimport java.io.*;\r\n\r\npublic class Main {\r\n public static int findSmallestDivisor(int[]nums,int th) {\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 //input work\r\n int n = scn.nextInt();\r\n int[]nums = new int[n];\r\n\r\n for(int i=0 ; i < n ; i++) {\r\n nums[i] = scn.nextInt();\r\n }\r\n\r\n int th = scn.nextInt();\r\n\r\n int speed = findSmallestDivisor(nums,th);\r\n System.out.println(speed);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"4\r\n1 2 5 9\r\n6","sampleOutput":"5","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":"da246144-e404-4107-b846-327a46427586","name":"Find The Smallest Divisor Given A Threshold","slug":"find-the-smallest-divisor-given-a-threshold","type":1}],"next":{"id":"e11863db-f2d3-4baf-87cd-796af9631b8e","name":"Find The Smallest Divisor Given A Threshold","type":3,"slug":"find-the-smallest-divisor-given-a-threshold"},"prev":{"id":"8445462b-c40a-49a5-ba16-b3c32921aaec","name":"Koko Eating Bananas MCQ","type":0,"slug":"koko-eating-bananas-mcq"}}}
plane

Editor


Loading...

Find The Smallest Divisor Given A Threshold

medium

1. Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result. Find the smallest divisor such that the result mentioned above is less than or equal to threshold. 2. Each result of the division is rounded to the nearest integer greater than or equal to that element. (For example: 7/3 = 3 and 10/2 = 5). 3. It is guaranteed that there will be an answer.

Constraints

1 <= nums.length <= 5 * 10^4 1 <= nums[i] <= 10^6 nums.length <= threshold <= 10^6

Format

Input

Input is managed for you

Output

Output is managed for you

Example

Sample Input

4 1 2 5 9 6

Sample Output

5

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode