The McAfee Tragedy
Problem Statement:
While McAfee mourned its founder’s death, it was threatened by a group of anonymous hackers that have given them an array A with N integers and an integer K. Solving this array by finding the number of quadruples (i, j, k, l) such that 1 ≤ i < j < k < l ≤ N and Ai, Aj, Ak, Al add up to K, will indicate the number of servers that have been infected in their South China Sea cluster.
Your job is to find this number to solve this small piece of the puzzle.
Constraints:
Subtask 1: 20 points
- 1 ≤ N ≤ 50
Subtask 2: 30 points
- 1 ≤ N ≤ 100
Subtask 3: 50 points
- 1 ≤ N ≤ 1000
Input Format:
- The first line contains two space seperated integers N and K
- The next line contains N space separated integers denoting the elements of A
Output Format:
- Print a single integer that is the number of quadruples which satisfy the given criteria
Sample Input:
6 9 1 3 4 2 4 2 Sample output:
2