QOJ.ac

QOJ

実行時間制限: 5.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓

#9082. 硬币

統計

“The Coin is invaluable.”

如果你相信这一点,那就买下它,然后再卖掉!

The Coin 的价格会随时间波动,但现在你可以预测未来 $n$ 天的市场价格!

然而,由于 The Coin 的魔力,如果你卖出它的次数超过一次,你必须注意:如果两次连续卖出之间的天数超过 $L$,你将因为贪婪而受到惩罚(WA)。

现在,你能想象在卖出次数不超过 $m$ 次的情况下,你能获得多少收益吗?

别忘了,你是一个富人,所以你不需要担心买入时的价格。

输入格式

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

接下来有 $2 \times T$ 行,每两行代表一个测试用例。

每个测试用例的第一行包含三个整数 $n, L, m$ ($1 \le L \le n \le 10^5, 1 \le m \le 100$),含义如上所述。

第二行包含 $n$ 个整数,表示 The Coin 在未来 $n$ 天的价格,每个价格都小于 $10^9$ 且大于 $0$。

你应该注意,你最初并没有 The Coin。

输出格式

请准确打印 $T$ 行。

对于每个测试用例,首先打印 Case d:($d$ 表示测试用例的序号),然后跟上对应测试用例的答案。

样例

输入 1

3
5 1 2
2 32 4 2 32
5 2 2
2 32 4 2 32
5 5 5
32 16 8 4 2

输出 1

Case 1: 30
Case 2: 32
Case 3: 0

说明

  • 样例 1:你可以在第一天买入,在第五天卖出。
  • 样例 2:你可以在第一天买入,在第三天卖出。然后可以在第四天买入,在第五天卖出。 你应该注意,你不能在第二天和第五天卖出,因为它们之间的天数超过了 $L = 2$ 天。
  • 样例 3:你对 The Coin 什么也做不了。

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.