Tap here to switch tabs
Problem
Submissions

Problem: Distribute Candies to People

med
30 min
Try to solve the Distribute Candies to People problem.

Statement

You are given an integer candies representing the total number of candies available, and an integer num_people representing the number of people standing in a line.

The candies are distributed in rounds:
We give 11 candy to the first person, 22 candies to the second person, and continue this pattern until giving num_people candies to the last person.
Then, we return to the first person and give num_people +1+ 1 candies to the first person, num_people +2+ 2 candies to the second person, and so on.
This process continues until we run out of candies. If there are not enough candies remaining to satisfy the required amount for the current person, that person receives all the remaining candies, and the distribution ends.

Return an array of length num_people representing the total number of candies each person receives.

Constraints:

  • 1≤1 \leq candies ≤109\leq 10^9

  • 1≤1 \leq num_people ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Distribute Candies to People

med
30 min
Try to solve the Distribute Candies to People problem.

Statement

You are given an integer candies representing the total number of candies available, and an integer num_people representing the number of people standing in a line.

The candies are distributed in rounds:
We give 11 candy to the first person, 22 candies to the second person, and continue this pattern until giving num_people candies to the last person.
Then, we return to the first person and give num_people +1+ 1 candies to the first person, num_people +2+ 2 candies to the second person, and so on.
This process continues until we run out of candies. If there are not enough candies remaining to satisfy the required amount for the current person, that person receives all the remaining candies, and the distribution ends.

Return an array of length num_people representing the total number of candies each person receives.

Constraints:

  • 1≤1 \leq candies ≤109\leq 10^9

  • 1≤1 \leq num_people ≤1000\leq 1000