P12085 [Lanqiao Cup 2023 NOI Qualifier B] Integer Deletion
Description
Given an integer sequence of length $N$: $A_{1}, A_{2}, \ldots, A_{N}$. You need to repeat the following operation $K$ times:
Each time, choose the smallest integer in the sequence (if the minimum value appears more than once, choose the leftmost one), delete it, and add its value to the integers adjacent to it.
Output the sequence after $K$ operations.
Input Format
The first line contains two integers $N$ and $K$.
The second line contains $N$ integers: $A_{1}, A_{2}, A_{3}, \ldots, A_{N}$.
Output Format
Output $N - K$ integers, separated by a single space, representing the sequence after $K$ operations.
Explanation/Hint
**Sample Explanation**
The sequence changes as follows. The number in brackets is the number chosen in that operation:
```plain
[1] 4 2 8 7
5 [2] 8 7
[7] 10 7
17 7
```
**Constraints**
For $20\%$ of the testdata, $1 \leq K < N \leq 10^4$.
For $100\%$ of the testdata, $1 \leq K < N \leq 5 \times 10^{5}$, and $0 \leq A_{i} \leq 10^{8}$.
Lanqiao Cup 2023 NOI Qualifier B Group, Problem H.
Translated by ChatGPT 5