#P10366. [PA 2024] Bardzo Ulubiony Ciąg
[PA 2024] Bardzo Ulubiony Ciąg
Background
PA 2024 5C1
Problem Description
This problem is translated from Round 5 of PA 2024, Bardzo Ulubiony Ciąg. Thanks to Macaronlin for providing the translation.
Given an integer array of length , all subarray sums of form an array of length . The subarray sums are ordered by increasing starting index of the subarray; if two subarrays have the same starting index, they are ordered by increasing ending index.
For the newly formed array , compute the number of triples such that .
Input Format
The first line contains an integer , the length of array .
The second line contains integers , representing array .
Output Format
Output one integer: the number of triples in array satisfying .
3
7 -4 -2
1
10
0 0 0 0 0 0 0 0 0 0
26235
Hint
Sample Explanation 1
Array is . Only the three distinct elements satisfy the condition, so the answer is .
Sample Explanation 2
Array consists of zeros. Any choice of three indices has sum , so the answer is .
Translated by ChatGPT 5