Delete numbers - MarisaOJ: Marisa Online Judge

Delete numbers

Time limit: 1500 ms
Memory limit: 256 MB
Given an array $A$ of $n$ integers indexed $0,1,...,n-1$. You will perform the following operation $n$ times: - Delete the maximum elements among elements with indices $0, k, 2 \times k,...$, if there are multiple maximum elements, delete the one with the smallest index. Find the deleted element at each step. ### Input - The first line contains 2 integers $n, k$. - The second line contains $n$ integers $A_i$. ### Output - Print the deleted element after each step. ### Constraints - $1 \le k \le n \le 10^5$. - $1 \le A_i \le n$. ### Example Input: ``` 10 3 2 3 1 9 10 4 5 6 1 5 ``` Output: ``` 9 10 4 5 6 2 5 3 1 1 ```