#P7868. [COCI 2015/2016 #2] VUDU
[COCI 2015/2016 #2] VUDU
Problem Description
Young Mirko has been buying voodoo dolls lately. Considering that he is very interested in the cheapest purchase possible, he has been tracking the prices of voodoo dolls each day.His price list consists of doll prices in the last days, where doll price represents the price of a doll days ago.
Mirko thinks he has noticed a connection between the average doll price in a sequence of consecutive days and the price on the following day. He wants to test his hunch and is puzzled by a very interesting question: "For a given , how many different consecutive subsequences in the last days are there, when the average doll price was greater than or equal to ?"
Two consecutive subsequences are considered different if their beginnings or ends are different.
Input Format
The first line of input contains the integer , the sequence length.
The second line of input contains prices .
The third line of input contains an integer .
Output Format
The first and only line of output must contain the answer to Mirko's question for a given .
3
1 2 3
3
1
3
1 3 2
2
5
3
1 3 2
3
1
Hint
Clarification of the first example
The only subsequence that has an average greater than or equal to is .
Clarification of the second example
The subsequences that have an average greater than or equal to are , , , , .
Scoring
In test cases worth of the points, .
In test cases for all points, , , .
Notes
The scoring for this problem follows the original problem, with a full score of .
From COCI 2015-2016 CONTEST #2 T5 VUDU.
Organized by