We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Mathematics
  3. Combinatorics
  4. Number List

Number List

Problem
Submissions
Leaderboard
Discussions
Editorial

Sam is playing with an array, , of positive integers. Sam writes a list, , containing all 's contiguous subarrays, and then replaces each subarray with its respective maximum element.

For example, consider the following where :

Subarrays of :
Updated (Maximum) Subarrays:

Help Sam determine how many numbers in are greater than .

Input Format

The first line contains a single integer, (the number of test cases). Each test case is described over two lines:
The first line of each test case contains two space-separated integers, (the number of elements in array ) and , respectively.
The second line of each test case contains space-separated integers describing the elements in .

Constraints




.

Output Format

For each test case, print the number of in on a new line.

Sample Input

2
3 2
1 2 3 
3 1 
1 2 3 

Sample Output

3
5

Explanation

Both test cases use the same as described in the Problem Statement, so for both test cases.

Test Case 0:
has elements , so we print .

Test Case 1:
has elements , so we print .

Author

ma5termind

Difficulty

Medium

Max Score

50

Submitted By

1318

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature