#P11221. [COTS 2019] 序列操作 K-ti

    ID: 12460 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2019分块COCI(克罗地亚)链表根号分治

[COTS 2019] 序列操作 K-ti

Background

Translated from D1T1 of Izborne Pripreme 2019 (Croatian IOI/CEOI Team Selection). 2s,0.5G\texttt{2s,0.5G}.

Problem Description

You are given a sequence of positive integers a0,a1,,aN1a_0, a_1, \cdots, a_{N-1} of length NN and a positive integer kk. Note that it is 0-indexed\texttt{0-indexed}.

Perform NN operations to delete all elements of aa. For each operation:

  • Let the current length of aa be nn.
  • Let S={0,k,2k,,kn1k}S=\{0,k,2k,\cdots,k\lfloor\frac{n-1}{k}\rfloor\}. Find v=maxiSaiv=\max_{i\in S} a_i.
  • Let pp be miniS,ai=vi\min_{i\in S, a_i=v} i.
  • Delete apa_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,kN, k.

The second line contains NN positive integers describing aa.

Output Format

Output NN lines, each containing one integer: the number deleted in each operation.

10 2
2 3 1 9 10 4 5 6 1 5
10
6
4
5
2
9
3
5
1
1
10 3
2 3 1 9 10 4 5 6 1 5
9
10
4
5
6
2
5
3
1
1

Hint

Constraints

For 100%100\% of the testdata, it is guaranteed that:

  • 2kN1052 \le k \le N \le 10^5.
  • 1aiN1 \le a_i \le N.
Subtask ID NN \le kk Score
11 10001\,000 N\le N 77
22 10510^5 =2=2 2525
33 10\le 10 2323
44 100\ge 100 2525
55 N\le N 2020

Translated by ChatGPT 5