CF2192C.All-in-one Gun

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are developing a new shooter game, but since there are a lot of shooter games out there, you decide to have something unique in your game.

You have an all-in-one gun that shoots bullets in a fixed order. There are nn bullets in the magazine, the ii-th of which deals aia_i damage. The enemy starts with hh health and dies when its health becomes ≤0\le 0.

The gun shoots one bullet per second. After firing all nn bullets, it must reload, which takes kk seconds. Reloading always restores the same sequence of bullets [a1,a2,…,an][a_1, a_2, \ldots, a_n]. You cannot reload early; you must empty the magazine first. At the start, the magazine is already full.

Before the fight begins, you may perform at most one swap: pick any indices 1≤i<j≤n1 \le i \lt j \le n and exchange aia_i with aja_j.

Your task is to find the minimum number of seconds needed to kill the enemy, taking into account this optional single swap.

你正在开发一款全新的射击游戏,但由于市面上已存在大量同类游戏,你决定为自己的游戏加入一些独特元素。

你拥有一把“全能型”枪械,它以固定顺序发射子弹。弹匣中共有 nn 发子弹,其中第 ii 发子弹造成 aia_i 点伤害。敌人初始生命值为 hh,当其生命值 ≤0\le 0 时即被击杀。

该枪每秒发射一发子弹。射完全部 nn 发子弹后,必须进行装填,耗时 kk 秒。每次装填均会恢复完全相同的子弹序列 [a1,a2,…,an][a_1, a_2, \ldots, a_n]。你不能提前装填;必须先将弹匣打空。游戏开始时,弹匣已处于满载状态。

在战斗开始前,你最多可执行一次交换操作:任选下标 1≤i<j≤n1 \le i \lt j \le n,交换 aia_i 与 aja_j 的值。

你的任务是:考虑这一可选的单次交换操作,求出击杀敌人所需的最短时间(单位:秒)。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

The first line of each testcase contains three integer nn, hh and kk (2≤n≤2⋅1052 \le n \le 2\cdot 10^5, $ 1 \le h, k \le 10^9$) — the size of magazine, health of your enemy and time required to reload the magazine.

The second line of each testcase contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \le a_i \le 10^9).

It is guaranteed that the sum of nn does not exceed 2⋅1052 \cdot 10^5 over all test cases.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例的第一行包含三个整数 nn、hh 和 kk(2≤n≤2⋅1052 \le n \le 2\cdot 10^5,1≤h,k≤1091 \le h, k \le 10^9)——分别表示弹匣容量、敌人的生命值以及重新装填弹匣所需的时间。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \le a_i \le 10^9)。

保证所有测试用例中 nn 的总和不超过 2⋅1052 \cdot 10^5。

输出格式

For each testcase, output a single integer denoting the minimum time required to kill the enemy.

对于每个测试用例,输出一个整数,表示击杀敌人的最短时间。

输入输出样例

  • 输入#1

    6
    5 10 1
    4 2 3 5 3
    5 10 1
    4 2 3 7 3
    3 10 2
    1 2 3
    2 5 3
    2 1
    3 18 5
    1 2 3
    4 10 10
    1 1 2 2

    输出#1

    3
    2
    7
    6
    19
    17

说明/提示

In the first test case, you swap the bullets present at index 22 and 55. This makes array aa as 4,3,3,5,24, 3, 3, 5, 2.

After 33 seconds, the health of your enemy will be 10−4−3−3=010 - 4 - 3 - 3 = 0, hence the enemy dies in 33 seconds. It can be shown that achieving time to kill less than 33 is not possible.

In the third test case, you swap bullets present at index 11 and 33. This makes array aa as 3,2,13, 2, 1.

In 77 seconds, you shoot the entire first magazine (33 seconds) ++ reload a new magazine (22 seconds) ++ shoot the first and the second bullet from the new magazine (22 seconds).

The health of the enemy will be 10−3−2−1−3−2=−110 - 3 - 2 - 1 - 3 - 2 = -1, hence the enemy dies in 77 seconds. It can be shown that achieving time to kill less than 77 is not possible.

在第一个测试用例中,你交换了索引为 22 和 55 处的子弹。这使得数组 aa 变为 4,3,3,5,24, 3, 3, 5, 2。

经过 33 秒后,敌人的生命值为 10−4−3−3=010 - 4 - 3 - 3 = 0,因此敌人在 33 秒内死亡。可以证明,无法将击杀时间缩短至少于 33 秒。

在第三个测试用例中,你交换了索引为 11 和 33 处的子弹。这使得数组 aa 变为 3,2,13, 2, 1。

在 77 秒内,你完成了以下操作:射空第一本弹匣(耗时 33 秒)++ 更换新弹匣(耗时 22 秒)++ 从新弹匣中射出第一颗和第二颗子弹(耗时 22 秒)。

敌人的生命值为 10−3−2−1−3−2=−110 - 3 - 2 - 1 - 3 - 2 = -1,因此敌人在 77 秒内死亡。可以证明,无法将击杀时间缩短至少于 77 秒。

输入解题思路,AI测评打分。不知道怎么写?

首页