All Submissions


Given an array A[1..N] of N integers & Q queries each specifying a number K .
For each array ,you have to tell how many contiguous subarrays have their minimum element as K.

N,K,A[i] <=100000
Q <=10000

Input:
Input contains many test cases(<=20).Read till EOF.
First line of each test case consists of a single integer N.
Next line contains N integers.
Next line gives number of Queries Q, followed by Q values of K.

Output:
For each query print the required number of subarrays in a new line.
Print a blank line between 2 test cases.

Sample Input:
4
5 7 2 4
3 2 5 0
3
1 2 1
2 1 2


Sample Output:
6
2
0

5
1

Problem Setter : Jayant Mukherji

Languages: AWK,Bash,Brain,C,C++,Java,C#,JavaScript,Pascal,Perl,PHP,Python,Python3,Ruby,Text

Time Limit: 2 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0