QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100

#3371. 工作中睡觉

统计

你在工作中。不幸的是,下班后紧接着就有一场编程竞赛。为了表现出色,你需要在工作中通过睡觉来尽可能多地恢复精力。你的工作日时长为 $N$ 分钟,每一分钟都有一个精力值 $e_0, e_1, \dots, e_{N-1}$。你的睡眠需求正好是 $M$ 分钟,但为了不被老板发现,你连续睡觉的时间不能超过 $R$ 分钟。如果你连续睡觉,会有额外的奖励:连续睡眠的第 $i$ 分钟,其精力值会乘以 $i$。例如,如果你连续睡了三分钟,对应的精力值分别为 10、10 和 9,你将获得 $10 + 2 \cdot 10 + 3 \cdot 9 = 57$ 的精力。当你睡够 $M$ 分钟后,你就完全休息好了,当天不能再睡觉。你决定编写一个计算机程序,计算在给定的工作日内你能获得的最大精力值。

输入格式

输入的第一行包含一个整数 $T$,表示测试用例的数量。每个测试用例的第一行包含三个整数 $N$(工作日的分钟数)、$M$(睡眠需求分钟数)和 $R$(不被老板发现的情况下,连续睡眠的最大分钟数)。接下来一行包含 $N$ 个整数 $e_0, e_1, \dots, e_{N-1}$,表示每一分钟的精力值。

输出格式

对于每个测试用例,输出一行,包含一个数字,表示总共睡够 $M$ 分钟所能获得的最大精力值;如果无法满足睡眠需求,则输出 impossible

数据范围

  • $0 < T \le 100$
  • $0 < N \le 500$
  • $0 < M \le 50$
  • $0 < R \le 50$
  • $0 \le e_i \le 100$
  • 你只能在时钟的分钟指示器改变时开始和停止睡觉。

样例

样例输入 1

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

样例输出 1

57
impossible

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.