Given array A of N (N <= $10^6$ ) elements (Ai <= $10^9$ ). Given Q queries (Q <= $10^6$ ). Every query consist of number K (K <= $10^9$ ). 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-> [2], [1,2] ↵
4 -> [1,2,3], [2,3], [3], [3] ↵
8 -> [1,2,3,4], [1,2,3,4,3], [2,3,4], [2,3,4,3], [3,4], [3,4,3], [4], [4,3]
↵
Test case: ↵
5 ↵
1 2 3 4 3 ↵
3 ↵
2 ↵
3 ↵
4 ↵
Output: ↵
2
4 ↵
8
4 -> [1,2,3], [2,3], [3], [3] ↵
8 -> [1,2,3,4], [1,2,3,4,3], [2,3,4], [2,3,4,3], [3,4], [3,4,3], [4], [4,3]