AT_arc229_c.Sum of Average 2
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a length-N sequence of positive integers A=(A1,A2,…,AN).
Find the minimum possible value of i=1∑N−1⌊2Ai+Ai+1⌋ after rearranging A in any order.
You are given T test cases; solve each of them.
给你一个长度为 N 的正整数序列 A=(A1,A2,…,AN)。
在对 A 进行任意重排后,求 i=1∑N−1⌊2Ai+Ai+1⌋ 的最小可能值。
你将得到 T 组测试数据;请分别求解每组数据。
输入格式
The input is given from Standard Input in the following format:
T
case1
case2
⋮
caseT
Each test case is given in the following format:
N
A1 A2 … AN
输入从标准输入中按以下格式给出:
T
case1
case2
⋮
caseT
每个测试用例按以下格式给出:
N
A1 A2 … AN
输出格式
Output the answers for the test cases in order, separated by newlines.
按顺序输出测试用例的答案,答案之间用换行符分隔。
输入输出样例
输入#1
4 4 1 2 4 3 3 4 4 4 5 3 1 4 1 5 10 278117031 167642909 517897721 148434323 567739597 319926999 481642530 659199879 252516557 49913403
输出#1
5 8 9 2829561210
说明/提示
Sample 1 Explanation:
Consider the first test case.
For example, rearranging A as (3,2,1,4) gives i=1∑N−1⌊2Ai+Ai+1⌋=⌊25⌋+⌊23⌋+⌊25⌋=5.
No matter how A is rearranged, the value of i=1∑N−1⌊2Ai+Ai+1⌋ is at least 5, so the answer is 5.
Constraints
- 1≤T≤105
- 2≤N≤2×105
- 1≤Ai≤109
- The sum of N over all test cases is at most 2×105.
- All input values are integers.
样例 1 解释:
考虑第一个测试用例。
例如,将 A 重排为 (3,2,1,4),可得
i=1∑N−1⌊2Ai+Ai+1⌋=⌊25⌋+⌊23⌋+⌊25⌋=5。
无论 A 如何重排,i=1∑N−1⌊2Ai+Ai+1⌋ 的值均不小于 5,因此答案为 5。
约束条件
- 1≤T≤105
- 2≤N≤2×105
- 1≤Ai≤109
- 所有测试用例的 N 之和不超过 2×105。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?