Quals-I-2011-2
You are given an array of integers A = ( a1 , ..., a[[N ]]). Let us consider a set of all sums of the consecutive elements of the array, denoted by S = { ai + ... + aj | 1 <= i <= j <= N}.
You should print the most frequent value from the set S, along with its frequency. In case of tie, print the greatest value.
InputIn the first line of the standard input you will be given N (1 <= N <= 3000). In the next line you will be given N non-negative integer values a1 , ..., a[[N ]], respectively, every within the interval [0, 3000].
OutputOn the first and the only line of the standard output print the two numbers as explained in the problem statement.
Note: For 30% test cases 1 <= N <= 100.
Input:
Output:
Explanation:
Set S = {1, 1 + 2, 1 + 2 + 3, 2, 2 + 3, 3} = {1, 3, 6, 2, 5, 3}.
3
1 2 3Output:
3 2Explanation:
Set S = {1, 1 + 2, 1 + 2 + 3, 2, 2 + 3, 3} = {1, 3, 6, 2, 5, 3}.
Input:
Output:
Explanation:
Note that sum 11 appears 3 times as well, but sum 30 is a greater one.
8
17 13 17 13 5 6 5 6Output:
30 3Explanation:
Note that sum 11 appears 3 times as well, but sum 30 is a greater one.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.