Split the Candy!


Submit solution

Points: 4 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

A group of \(M\) students go trick-or-treating together to \(N\) houses.
Each house gives a certain number of candies, but the students share them evenly.

In other words, for each house:

  • Each student receives \(floor(candies[i] / M)\) candies.
  • Any leftover candies are wasted.

Determine how many candies each student has after visiting all houses.

The floor of a number is the largest integer less than or equal to that number. For example, \(floor(2.4)=2\) and \(floor(3.7)=3\).

Input Specification

The first line contains two integers \(M\) and \(N\) (\(1 ≤ M, N ≤ 1000\)).
The second line contains \(N\) space-separated integers \(candies[i]\) (\(1 ≤ candies[i] ≤ 1000\)).

Output Specification

Print one integer — the total number of candies each student receives after visiting all houses.

Sample Input

3 4
6 7 3 10

Sample Output

8

Comments

There are no comments at the moment.