QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 64 MB مجموع النقاط: 100

#6868. 可莉喜欢交朋友

الإحصائيات

Klee 喜欢交朋友,现在有 $n$ 个人站成一排,Klee 与第 $i$ 个人交朋友的代价为 $a_i$。Klee 有一个原则:在任意连续的 $m$ 个人中,至少要有 $2$ 个是她的朋友。请帮她计算所需的最小总代价。

输入格式

输入的第一行包含一个整数 $T$ ($1 \le T \le 20$),表示测试用例的数量。

每个测试用例中: 第一行包含两个整数 $n, m$ ($2 \le n \le 20000, 2 \le m \le 2000, m \le n$)。 第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 20000$)。

保证所有测试用例中 $\sum n \le 50000$。

输出格式

对于每个测试用例: 输出一个整数,表示最小代价。

样例

输入格式 1

1
7 3
1 5 7 2 1 4 8

输出格式 1

13

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.