All Tracks Data Structures Hash Tables Basics of Hash Tables Problem

Cricket Balls
/
No tags
Problem
Editorial
Analytics

Daksh has 'N' boxes of cricket balls and each box has certain number of cricket balls (non-zero) in it. The boxes are numbered from 1 to N.

Now, Daksh has to go for practicing to cricket ground to compete in the upcoming fest URJA. Daksh wants to carry exactly K number of cricket balls to ground and he can carry only 2 boxes. Can you tell him the number of ways in which he can select 2 boxes such that total number of cricket balls in them is K.

Input :

  • First line of the input is the number of test cases T.
  • Each test case has 3 lines. First line is the number of boxes N.
  • Next line has N space separated integers where the ith integer is the number of cricket balls in the ith box.
  • 3rd line of each test case contains value of K.

Output:

  • For each test case, output a single number, the number of ways in which Daksh can select the boxes.

Constraints:

  • 1<=T<=100
  • 1<=N<=105
  • 1<=Number of Balls in ith box<=100
SAMPLE INPUT
2
5
1 2 3 4 3
6
5
1 5 3 3 3
6
SAMPLE OUTPUT
2
4
Explanation

None

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

Initializing Code Editor...
Notifications
View All Notifications

?