Chocolate distribution
Practice
3.1 (21 votes)
Approved
Basic programming
Basics of implementation
Easy
Grammar Verified
Implementation
Math
Ready
Recruit
Problem
53% Success 3717 Attempts 20 Points 3s Time Limit 256MB Memory 1024 KB Max Code

There are $$N$$ people standing in a row with some \(count_i\) $$(1 \le i \le N)$$ number of chocolates in their hands. You have to select a range of people and take all their chocolates with the condition that you should be able to distribute those chocolates equally among $$M$$ boxes.

Write a program to determine the maximum number of chocolates that can be placed in a box.

Input format

  • First line: $$T$$ (number of test cases)
  • First line in each test case: Two space-separated integers $$N$$ and $$M$$
  • Second line in each test case: $$N$$ space-separated integers (denoting the number of chocolates)

Output format

For each test case, print the maximum number of chocolates that can be placed in a box.

Constraints

\(1 ≤ T ≤10^3\)
\(1 ≤ N, M ≤10^5\)
\(0 ≤ Count_i ≤10^5\)
Sum of $$N$$ over all test cases \(\le10^7\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
72 votes
Tags:
EasyMath
Points:20
58 votes
Tags:
ApprovedEasyImplementationOpen
Points:20
38 votes
Tags:
Ad-HocApprovedBasic ProgrammingEasyImplementation