← Back to Problems
Take It or Leave It
Medium optimization Probability & Statistics Games & Strategy
Time limit: 4 s per test  ·  Memory: 256 MB

You will receive n offers, one at a time, in uniformly random order. All n offers are distinct in quality, but you never see the qualities themselves: when offer i arrives, you learn only its rank among the i offers seen so far (1 = best so far). You must accept or reject each offer on the spot; rejected offers are gone, and you may accept at most one.

You win if the offer you accept is among the m best of all n. If you never accept, you lose.

Choose your strategy. A strategy is a threshold rule: at step i, accept the offer if its rank among the first i is at most t_i, and reject otherwise.

Input

One line with the integers n and m.

Output

n integers t_1, ..., t_n with 0 <= t_i <= i (t_i = 0 means never accept at step i).

Scoring

Your score is P / P*, where P is the exact probability that your strategy wins and P* is the best achievable probability.

Constraints

1 <= m <= 10

m <= n <= 200

Examples

input
10 1
possible output
0 0 0 0 1 1 1 1 1 1
This output receives a score of 1.00.
input
12 3
possible output
0 0 0 0 2 2 2 2 2 2 2 2
This output receives a score of 0.84.
Python 3.13 i Execution environment Isolated microVM · 1 vCPU · no internet access Time and memory limits are set per problem Available packages numpy 2.5.0scipy 1.18.0pandas 3.0.0scikit-learn 1.9.0statsmodels 0.15.0cvxpy 1.9.2
Discussion
No comments yet. Kick off the discussion.