QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#16493. Equal

Statistics

题目描述

有一个长度为 $n$ 的非负整数序列 $a$,你可以无限的做以下两种操作,使得序列中的每一个数字都相等:

  • 花费 $x$ 的代价,使得对于所有不大于 $n$ 的正整数 $i$,$a_i$ 的值变为 $\max(a_i-1,0)$;
  • 花费 $y$ 的代价,替换序列中的一个数为任意数字;

求需要花费的最小代价。

输入格式

每个测试点有多组测试数据

第一行一个整数 $t$,表示数据组数。

接下来依次输入 $t$ 组测试数据。

对于每一组测试数据,第一行三个正整数 $n,x,y$,表示序列长度,第一种操作的代价和第二种操作的代价;第二行 $n$ 个非负整数 $a_1,a_2......a_n$($1\le n \le 2\times10^5$,$0 \le x,y,a_i \le 10^9$)。

保证对于单个测试点,所有 $n$ 的和不超过 $2\times 10^5$。

输出格式

对于每一组测试数据,输出一行一个整数,表示需要花费的最小代价。

样例

输入样例 #1

3
2 4 2
3 10
5 2 1
1 2 2 1 1
5 3 8
0 1 2 3 2

输出样例 #1

2
2
9

样例解释

对于第一组数据,可以进行 $1$ 次第二种操作,把 $a_2$ 的值修改为 $3$,此时 $a_1=a_2=3$。

对于第二组数据,可以进行 $2$ 次第二种操作,把 $a_2$ 和 $a_3$ 的值修改为 $1$,此时 $a_1=a_2=a_3=a_4=a_5=1$。

对于第三组数据,可以进行 $3$ 次第一种操作,此时 $a_1=a_2=a_3=a_4=a_5=0$。

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.