시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 142 | 105 | 89 | 76.724% |
You are given an integer array of size N and an integer M. This array has (N*(N-1))/2 different pairs. You need to calculate how many of those pairs have the sum equal to M. For example, if the array is {1,2,3,4} and M is 5, then there are exactly 2 pairs {1,4} and {2,3} whose sum is equal to M.
The first line has a positive integer T, T <= 100,000, denoting the number of test cases. This is followed by each test case per line.
Each test case consists of two lines. The first line contains 2 integers N and M separated by a single space. N is between 2 and 20,000 inclusive. The second line consists of the N integers separated by a single space, denoting the values of the given array. All the numbers in the array are between 1 and 1,000,000,000 inclusive. They are distinct and sorted in increasing order.
For each test case, the output contains a line in the format Case #x: R, where x is the case number (starting from 1) and R is the number of pairs whose sum is exactly the given M.
5 8 100 19 25 32 48 52 68 75 81 8 100 19 28 31 49 51 61 72 81 8 100 16 22 38 46 58 62 73 81 8 100 13 21 32 48 52 67 78 87 8 100 13 24 34 43 57 61 76 81
Case #1: 4 Case #2: 3 Case #3: 1 Case #4: 2 Case #5: 2