P11221 [COTS 2019] Sequence Operations K-ti
Background
Translated from D1T1 of [Izborne Pripreme 2019 (Croatian IOI/CEOI Team Selection)](https://hsin.hr/pripreme2019/). $\texttt{2s,0.5G}$.
Description
You are given a sequence of positive integers $a_0, a_1, \cdots, a_{N-1}$ of length $N$ and a positive integer $k$. Note that it is $\texttt{0-indexed}$.
Perform $N$ operations to delete all elements of $a$. For each operation:
- Let the current length of $a$ be $n$.
- Let $S=\{0,k,2k,\cdots,k\lfloor\frac{n-1}{k}\rfloor\}$. Find $v=\max_{i\in S} a_i$.
- Let $p$ be $\min_{i\in S, a_i=v} i$.
- Delete $a_p$. The elements after it shift left by one position.
Output the number deleted in each operation.
Input Format
The first line contains two positive integers $N, k$.
The second line contains $N$ positive integers describing $a$.
Output Format
Output $N$ lines, each containing one integer: the number deleted in each operation.
Explanation/Hint
## Constraints
For $100\%$ of the testdata, it is guaranteed that:
- $2 \le k \le N \le 10^5$.
- $1 \le a_i \le N$.
| Subtask ID | $N \le$ | $k$ | Score |
| :--: | :--: | :--: | :--: |
| $1$ | $1\,000$ | $\le N$ | $7$ |
| $2$ | $10^5$ | $=2$ | $25$ |
| $3$ | $10^5$ | $\le 10$ | $23$ |
| $4$ | $10^5$ | $\ge 100$ | $25$ |
| $5$ | $10^5$ | $\le N$ | $20$ |
Translated by ChatGPT 5