CF1582E.Pchelyonok and Segments
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Pchelyonok decided to give Mila a gift. Pchelenok has already bought an array a of length n, but gifting an array is too common. Instead of that, he decided to gift Mila the segments of that array!
Pchelyonok wants his gift to be beautiful, so he decided to choose k non-overlapping segments of the array [l1,r1], [l2,r2], … [lk,rk] such that:
- the length of the first segment [l1,r1] is k, the length of the second segment [l2,r2] is k−1, …, the length of the k-th segment [lk,rk] is 1
- for each i<j, the i-th segment occurs in the array earlier than the j-th (i.e. ri<lj)
- the sums in these segments are strictly increasing (i.e. let sum(l…r)=i=l∑rai — the sum of numbers in the segment [l,r] of the array, then sum(l1…r1)<sum(l2…r2)<…<sum(lk…rk)).
Pchelenok also wants his gift to be as beautiful as possible, so he asks you to find the maximal value of k such that he can give Mila a gift!
佩切廖诺克决定送给米拉一份礼物。佩切廖诺克已经买好了一个长度为 n 的数组 a,但直接送一个数组太过普通。于是他决定改为送给米拉该数组的一些子区间!
佩切廖诺克希望他的礼物足够精美,因此他打算从该数组中选出 k 个互不重叠的子区间 [l1,r1], [l2,r2], …, [lk,rk],满足以下条件:
- 第一个子区间 [l1,r1] 的长度为 k,第二个子区间 [l2,r2] 的长度为 k−1,……,第 k 个子区间 [lk,rk] 的长度为 1;
- 对任意 i<j,第 i 个子区间在数组中出现在第 j 个子区间之前(即 ri<lj);
- 这些子区间的元素和严格递增(即令 sum(l…r)=i=l∑rai 表示数组中子区间 [l,r] 内所有数的和,则需满足 sum(l1…r1)<sum(l2…r2)<…<sum(lk…rk))。
佩切廖诺克还希望他的礼物尽可能精美,因此他请你找出满足上述条件的最大可能的 k 值!
输入格式
The first line contains a single integer t (1≤t≤100) — the number of test cases. The next 2⋅t lines contain the descriptions of test cases. The description of each test case consists of two lines.
The first line of each test case contains a single integer n (1≤n≤105) — the length of the array.
The second line contains n integers a1,a2,…,an (1≤ai≤109) — the elements of the array a.
It is guaranteed that the sum of n over all test cases does not exceed 105.
第一行包含一个整数 t(1≤t≤100),表示测试用例的数量。接下来的 2⋅t 行包含各测试用例的描述。每个测试用例的描述由两行组成。
每个测试用例的第一行包含一个整数 n(1≤n≤105),表示数组的长度。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109),表示数组 a 的元素。
保证所有测试用例的 n 之和不超过 105。
输出格式
For each test case, print the maximum possible value of k.
对于每个测试用例,输出 k 的最大可能值。
输入输出样例
输入#1
5 1 1 3 1 2 3 5 1 1 2 2 3 7 1 2 1 1 3 2 6 5 9 6 7 9 7
输出#1
1 1 2 3 1
输入解题思路,AI测评打分。不知道怎么写?