PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000241. Tổng các phần tử nhỏ nhất (Least Elements)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tổng các phần tử nhỏ nhất (Least Elements)

Least Elements

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given NN integers A1,…,ANA_1,\ldots,A_N, consider every contiguous window of exactly MM elements in left-to-right order. For each window, compute the sum of its KK smallest entries, counting repeated values with their multiplicity. Treat windows independently.

Input

The first line contains integers N,M,KN,M,K. The second contains NN integers A1,…,ANA_1,\ldots,A_N.

Output

Print N−M+1N-M+1 space-separated integers in window order.

Subtasks

  • Subtask 1 (20 points): 1≤K≤M≤N≤1001\le K\le M\le N\le 100; 1≤Ai≤1091\le A_i\le 10^9 for every 1≤i≤N1\le i\le N.
  • Subtask 2 (30 points): 1≤K≤M≤N≤2⋅1051\le K\le M\le N\le 2\cdot10^5; 1≤Ai≤1091\le A_i\le 10^9; K=MK=M; the bound on AiA_i applies for every 1≤i≤N1\le i\le N.
  • Subtask 3 (50 points): 1≤K≤M≤N≤2⋅1051\le K\le M\le N\le 2\cdot10^5; 1≤Ai≤1091\le A_i\le 10^9 for every 1≤i≤N1\le i\le N.

Examples

Input

5 3 2
7 2 2 9 1

Output

4 4 3

Explanation

The windows are (7,2,2)(7,2,2), (2,2,9)(2,2,9), and (2,9,1)(2,9,1). Their two smallest entries are (2,2)(2,2), (2,2)(2,2), and (1,2)(1,2), giving 4,4,3.