CF1471A.Strange Partition

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given an array aa of length nn, and an integer xx. You can perform the following operation as many times as you would like (possibly zero): replace two adjacent elements of the array by their sum. For example, if the initial array was [3,6,9][3, 6, 9], in a single operation one can replace the last two elements by their sum, yielding an array [3,15][3, 15], or replace the first two elements to get an array [9,9][9, 9]. Note that the size of the array decreases after each operation.

The beauty of an array b=[b1,…,bk]b=[b_1, \ldots, b_k] is defined as ∑i=1k⌈bix⌉\sum_{i=1}^k \left\lceil \frac{b_i}{x} \right\rceil, which means that we divide each element by xx, round it up to the nearest integer, and sum up the resulting values. For example, if x=3x = 3, and the array is [4,11,6][4, 11, 6], the beauty of the array is equal to ⌈43⌉+⌈113⌉+⌈63⌉=2+4+2=8\left\lceil \frac{4}{3} \right\rceil + \left\lceil \frac{11}{3} \right\rceil + \left\lceil \frac{6}{3} \right\rceil = 2 + 4 + 2 = 8.

Please determine the minimum and the maximum beauty you can get by performing some operations on the original array.

给你一个长度为 nn 的数组 aa 和一个整数 xx。你可以执行以下操作任意多次(包括零次):将数组中两个相邻的元素替换为它们的和。例如,若初始数组为 [3,6,9][3, 6, 9],则一次操作可以将后两个元素替换为其和,得到数组 [3,15][3, 15];也可以将前两个元素替换为其和,得到数组 [9,9][9, 9]。注意:每次操作后,数组长度都会减小。

数组 b=[b1,…,bk]b=[b_1, \ldots, b_k] 的**美观度(beauty)**定义为 ∑i=1k⌈bix⌉\sum_{i=1}^k \left\lceil \frac{b_i}{x} \right\rceil,即对每个元素除以 xx 后向上取整,再将所有结果相加。例如,当 x=3x = 3、数组为 [4,11,6][4, 11, 6] 时,该数组的美观度为 ⌈43⌉+⌈113⌉+⌈63⌉=2+4+2=8\left\lceil \frac{4}{3} \right\rceil + \left\lceil \frac{11}{3} \right\rceil + \left\lceil \frac{6}{3} \right\rceil = 2 + 4 + 2 = 8。

请确定:对原始数组执行若干次上述操作后,所能得到的最小和最大美观度分别是多少。

输入格式

The first input line contains a single integer tt — the number of test cases (1≤t≤10001 \le t \le 1000).

The first line of each test case contains two integers nn and xx (1≤n≤1051 \leq n \leq 10^5, 1≤x≤1091 \leq x \leq 10^9).

The next line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \leq a_i \leq 10^9), the elements of the array aa.

It is guaranteed that the sum of values of nn over all test cases does not exceed 10510^5.

第一行输入包含一个整数 tt —— 测试用例的数量(1≤t≤10001 \le t \le 1000)。

每个测试用例的第一行包含两个整数 nn 和 xx(1≤n≤1051 \leq n \leq 10^5,1≤x≤1091 \leq x \leq 10^9)。

接下来的一行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \leq a_i \leq 10^9),即数组 aa 的元素。

保证所有测试用例中 nn 的总和不超过 10510^5。

输出格式

For each test case output two integers — the minimal and the maximal possible beauty.

对于每个测试用例,输出两个整数——最小和最大的可能美观度。

输入输出样例

  • 输入#1

    2
    3 3
    3 6 9
    3 3
    6 4 11

    输出#1

    6 6
    7 8

说明/提示

In the first test case the beauty of the array does not change if we perform any operations.

In the second example we can leave the array unchanged to attain the maximum beauty, and to get the minimum beauty one can replace two elements 44 and 1111 with their sum, yielding an array [6,15][6, 15], which has its beauty equal to 77.

在第一个测试用例中,无论执行任何操作,数组的“美观度”均保持不变。

在第二个示例中,我们可以保持数组不变以获得最大美观度;而为了获得最小美观度,可将两个元素 44 和 1111 替换为它们的和,得到数组 [6,15][6, 15],其美观度为 77。

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

首页