Login

All Problems

Problem title

Difficulty

Avg time to solve

Find the K-th Smallest Element in Array

Easy

10 mins

Flip Equivalent Binary Tree

Moderate

25 mins

Path visiting all nodes

Hard

45 mins

Count Of Divisible Pairs

Easy

15 mins

Mirror Diagonals

Easy

--

NINJA KI GANIT

Moderate

20 mins

Minimum Numbers Required

Easy

15 mins

Split Array With Equal Sums

Moderate

15 mins

Insertion in a Priority queue -Max Heap

Easy

20 mins

Boxes Of Chocolates

Moderate

20 mins

Problem

Submissions

1

Avg. time to solve

20 min

Success Rate

86%

Problem Statement

```
Output: 2
If there is no restriction on choosing the boxes then the maximum number of chocolates the 5 students equally can have is 3 by picking all boxes except the box at index 2(0-based indexing). So total candies will be 3+2+5+4+1 = 15 and each of the 5 students will get 15/5=3 candies.
But we are allowed to choose only consecutive boxes. So if we choose boxes [0,1] then 3+2=5 then each student will have only 1 chocolate and when we choose boxes[4,6] as 5+4+1=10 then each student will have 2 chocolates. So the maximum number of chocolates each student can get is 2.
```

```
The first line of input contains a single integer T, representing the number of test cases or queries to be run.
Then the T test cases follow.
The first line of each test case contains two single space-separated integers N, and K, denoting the total number of boxes and the total number of students respectively.
The second line of each test case contains 'N' single space-separated integers representing the count of chocolates in each of the N boxes.
```

```
For each test case, print an integer denoting the maximum number of chocolates each child can get in a single line
```

```
1 <= T <= 10
1 <= N <= 10^5
1 <= K <= 10^5
0 <= boxes[i] <= 10^5
Time Limit: 1 sec
```

```
2
5 3
1 2 3 4 5
5 4
1 2 3 4 5
```

```
5
3
```

```
For the first test case, we can choose the boxes [0,4] as 1+2+3+4+5=15 each student will have 5 chocolates.
For the second test case, You can choose the boxes [2, 4] as 3+4+5=12, each student will have 3 chocolates.
```

```
1
5 8
1 2 3 4 5
```

```
0
```

```
For the first test case, there is no way to choose consecutive boxes and divide chocolates from those boxes equally among 8 students
```

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Language

Change Theme

Solution submission not allowed

Save Code

Reset Code