Number of subsegments with maximum element equal to K

Revision en1, by CopeCope, 2018-01-30 19:40:42

Given array A of N (N <= 106 ) elements (Ai <= 109 ). Given Q queries (Q <= 106 ). Every query consist of number K (K <= 109). For every query find number of subsegments such that their maximum element is K.

Test case:
5
1 2 3 4 3
3
2
3
4
Output:
2
4
8

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English CopeCope 2018-01-30 22:02:42 121 Tiny change: 'n4 \n8' -> 'n4 \n8 $->$'
en2 English CopeCope 2018-01-30 20:49:12 1 Tiny change: ' <= $10^9$). For eve' -> ' <= $10^9$ ). For eve'
en1 English CopeCope 2018-01-30 19:40:42 374 Initial revision (published)