## COCI '15 Contest 2 #5 Vudu

View as PDF

Points: 20 (partial)
Time limit: 0.6s
Java 1.0s
Python 1.0s
Memory limit: 64M

Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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 Specification

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 .

In test cases worth 30% of points the sequence length will be less than or equal to .

#### Output Specification

The first and only line of output must contain the answer to Mirko's question for a given .

#### Sample Input 1

3
1 2 3
3

#### Sample Output 1

1

#### Explanation for Sample Output 1

The only subsequence that has an average greater than or equal to is .

#### Sample Input 2

3
1 3 2
2

#### Sample Output 2

5

#### Explanation for Sample Output 2

The subsequences that have an average greater than or equal to are , , , ,

#### Sample Input 3

3
1 3 2
3

#### Sample Output 3

1