Title description:
Given an array, we call the consecutive elements in it a continuous subsequence, and the sum of these elements is the sum of consecutive subsequences. There may be several groups of consecutive subsequences in the array, and the consecutive subsequences in the group are disjoint and have the same sum. Find a set of contiguous subsequences with the largest number of subsequences in the group. Output this number.
Enter a description:
The first line of input is the array length N, 1 <= N <= 10^3.
The second line contains N integers Ci separated by spaces, -10^5 <= Ci <= 10^5.
Output description:
The first line is an integer M, indicating the maximum number of subsequences in the group that meet the requirements.
Supplementary note:
put away
Example 1
enter:
10 8 8 9 1 9 6 3 9 1 0output:
4illustrate:
The subscripts of the first and last elements of the four subsequences are:
2 2
4 4
5 6
7 7Example 2
enter:
10 -1 0 4 -3 6 5 -6 5 -7 -3output:
3illustrate:
The subscripts of the first and last elements of the three subsequences are:
3 3
5 8
9 9
Huawei OD machine test real questions - most equal and disjoint continuous subsequences [2023Q2] [JAVA, Python, C++]
Guess you like
Origin blog.csdn.net/2301_76848549/article/details/130174874
Recommended
Ranking