Processing math: 100%
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×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 Ai. ### Output - Print the deleted element after each step. ### Constraints - 1≤k≤n≤105. - 1≤Ai≤n. ### Example Input: 10323191045615 Output: 91045625311