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

#GD0000073. Một cách chia mảng khác (Yet Another Array Partitioning Task)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Một cách chia mảng khác (Yet Another Array Partitioning Task)

Yet Another Array Partitioning Task

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given an array a1,…,ana_1,\ldots,a_n and integers m,km,k, define the beauty of a contiguous segment of length at least mm as the sum of its mm largest elements (including negative values when present). Partition the entire array into exactly kk contiguous segments of length at least mm, maximizing the total beauty. Print the optimum and the k−1k-1 increasing endpoints of the first k−1k-1 segments.

Input

The first line contains n,m,kn,m,k. The second contains aia_i.

Output

Print the maximum total beauty. The next line must contain k−1k-1 integers p1<⋯<pk−1p_1<\cdots<p_{k-1} defining the contiguous segments. Any optimal valid partition is accepted.

Subtasks

  • Subtask 1 (20 points): 2≤n≤242\le n\le 24; 2≤k2\le k; 1≤m1\le m, mk≤nmk\le n; −109≤ai≤109-10^9\le a_i\le10^9 for every ii.
  • Subtask 2 (30 points): 2≤n≤20002\le n\le 2000; 2≤k2\le k; 1≤m1\le m, mk≤nmk\le n; −109≤ai≤109-10^9\le a_i\le10^9 for every ii.
  • Subtask 3 (50 points): 2≤n≤2000002\le n\le 200000; 2≤k2\le k; 1≤m1\le m, mk≤nmk\le n; −109≤ai≤109-10^9\le a_i\le10^9 for every ii.

Examples

Input

9 2 3
5 2 5 2 4 1 1 3 2

Output

21
2 4

Explanation

Cut positions 2, 4 produce segments [5,2], [5,2], [4,1,1,3,2]. Their beauties are 7, 7, 7, totaling 21. This matches the sum of the mkmk largest elements and is optimal.