CF2159D1.Inverse Minimum Partition (Easy Version)

省选/NOI-

通过率:0%

时间限制:4.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

This is the easy version of the problem. The difference between the versions is that in this version, you are only asked to find f(a)f(a). You can hack only if you solved all versions of this problem.

For some sequence bb of kk positive integers, the cost of the sequence is defined as follows∗^{\text{∗}}:

mathttcost(b)=leftlceilfracb_kmin(b_1,b_2,ldots,b_k)rightrceil\\mathtt{cost}(b)=\\left\\lceil{\\frac{b\_k}{\\min(b\_1,b\_2,\\ldots,b\_k)}}\\right\\rceil

Assume that you partition a sequence cc into one or more sequences, so that the sequences become cc when concatenated. For example, when the sequence cc is [3,1,4,1,5][3,1,4,1,5], a few valid ways to partition the sequence are [[3,1],[4,1,5]][[3,1],[4,1,5]], [[3],[1,4,1],[5]][[3],[1,4,1],[5]], [[3,1,4,1,5]][[3,1,4,1,5]]. On the other hand, [[3,1],[1,5]][[3,1],[1,5]] and [[3,4,1],[1,5]][[3,4,1],[1,5]] are not valid ways to partition the sequence.

For a partition of a sequence cc of positive integers, the total cost of the partition is defined as the sum of the costs of each sequence in the partition. Then, let us define f(c)f(c) as the minimum total cost to partition the sequence cc.

Given a sequence aa of nn positive integers, you must compute the value of f(a)f(a).

∗^{\text{∗}}Given a real value xx, ⌈x⌉\left\lceil{x}\right\rceil is defined as the smallest integer no less than xx. For example, the value of ⌈3.14⌉\left\lceil{3.14}\right\rceil is 44.

这是该问题的简单版本。两个版本的区别在于,在本版本中,你只需计算 f(a)f(a)。仅当你解决了该问题的所有版本时,才可进行 hack。

对于某个由 kk 个正整数组成的序列 bb,其代价定义如下∗^{\text{∗}}:

cost(b)=⌈bkmin⁡(b1,b2,…,bk)⌉\mathtt{cost}(b)=\left\lceil{\frac{b_k}{\min(b_1,b_2,\ldots,b_k)}}\right\rceil

假设你将一个序列 cc 划分为一个或多个子序列,使得将这些子序列按顺序拼接后恰好得到 cc。例如,当序列 cc 为 [3,1,4,1,5][3,1,4,1,5] 时,一些合法的划分方式包括 [[3,1],[4,1,5]][[3,1],[4,1,5]]、[[3],[1,4,1],[5]][[3],[1,4,1],[5]]、[[3,1,4,1,5]][[3,1,4,1,5]];而 [[3,1],[1,5]][[3,1],[1,5]] 和 [[3,4,1],[1,5]][[3,4,1],[1,5]] 则不是合法的划分方式。

对于一个由正整数组成的序列 cc 的某种划分,该划分的总代价定义为划分所得各子序列代价之和。接着,我们定义 f(c)f(c) 为划分序列 cc 所能得到的最小总代价。

给定一个长度为 nn 的正整数序列 aa,你需要计算 f(a)f(a) 的值。

∗^{\text{∗}} 对于任意实数 xx,⌈x⌉\left\lceil{x}\right\rceil 表示不小于 xx 的最小整数。例如,⌈3.14⌉=4\left\lceil{3.14}\right\rceil = 4。

输入格式

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 test case contains a single integer nn (1≤n≤4⋅1051 \le n \le 4\cdot 10^5).

The second line of each test case contains a1,a2,…,ana_1,a_2,\ldots,a_n (1≤ai≤10181 \le a_i \le 10^{18}).

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

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

每个测试用例的第一行包含一个整数 nn(1≤n≤4⋅1051 \le n \le 4\cdot 10^5)。

每个测试用例的第二行包含 a1,a2,…,ana_1,a_2,\ldots,a_n(1≤ai≤10181 \le a_i \le 10^{18})。

保证所有测试用例的 nn 之和不超过 4⋅1054\cdot 10^5。

输出格式

For each test case, output the answer to the problem on a separate line.

对于每个测试用例,在单独的一行上输出该问题的答案。

输入输出样例

  • 输入#1

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

    输出#1

    2
    4
    5
    2

说明/提示

For the first test case, the partition [[3,1,4,1],[5]][[3,1,4,1],[5]] gives a total cost of 1+1=21+1=2.

For the second test case, the partition [[9,2,6,5,3],[5,8,9,7,9]][[9,2,6,5,3],[5,8,9,7,9]] gives a total cost of 2+2=42+2=4.

For the third test case, the partition [[1],[2,3,4],[5,6,7,8]][[1],[2,3,4],[5,6,7,8]] gives a total cost of 1+2+2=51+2+2=5.

For the fourth test case, the partition [[1],[1 000 000 000 000 000 000]][[1],[1\,000\,000\,000\,000\,000\,000]] gives a total cost of 1+1=21+1=2.

对于第一个测试用例,划分 [[3,1,4,1],[5]][[3,1,4,1],[5]] 的总代价为 1+1=21+1=2。

对于第二个测试用例,划分 [[9,2,6,5,3],[5,8,9,7,9]][[9,2,6,5,3],[5,8,9,7,9]] 的总代价为 2+2=42+2=4。

对于第三个测试用例,划分 [[1],[2,3,4],[5,6,7,8]][[1],[2,3,4],[5,6,7,8]] 的总代价为 1+2+2=51+2+2=5。

对于第四个测试用例,划分 [[1],[1 000 000 000 000 000 000]][[1],[1\,000\,000\,000\,000\,000\,000]] 的总代价为 1+1=21+1=2。

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

首页