No.625 ソンタクロース
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Problem Statement
N Santa Clauses are trying to decide how to allocate M presents.
■ How the allocation of presents is decided
1. Among the active Santa Clauses, the one with the longest beard proposes an allocation of the presents.
2. The active Santa Clauses, including the proposer, each independently vote for or against it.
2.a. If a majority votes in favor, they go to deliver the presents with that allocation.
2.b. If a majority in favor is not obtained, the Santa Claus who proposed that allocation immediately retires.
3. Steps 1 and 2 are repeated until an allocation is decided.
■ Characteristics of Santa Clauses
Santa Clauses make decisions according to the following order of priority.
1. They want to deliver as many presents as possible.
2. Even having 0 presents allocated to themselves is preferable to retiring.
3. If the number of presents allocated to themselves is the same, they prefer a smaller number of active Santa Clauses.
4. They prefer that more presents be allocated to Santa Clauses with shorter beards.
The Santa Clauses are numbered from 1 to N in descending order of beard length.
Santa Claus 1 has the longest beard.
Given N and M,
output the number of presents allocated to each Santa Claus on a single line.
Represent the number of presents allocated to a retired Santa Claus by -1.
Input
N MThe number of Santa Clauses N and the number of presents M are given, separated by a space.
1 <= N <= 1000
1 <= M <= 20000
Output
Output the number of presents allocated to each Santa Claus on a single line.
Print a newline at the end.
Sample
Sample 1
Input
3 5
Output
5 0 0
Sample 2
Input
1 100
Output
100
Sample 3
Input
8 3
Output
-1 0 1 0 0 1 0 1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
matsu7874