OPCPIZZA - Pizzamania
Singham and his friends are fond of pizza. But this time they short of money. So they decided to help each other. They all decided to bring pizza in pairs. Our task is to find the total number of pairs possible which can buy pizza, given the cost of pizza. As pizza boy don't have any cash for change, if the pair adds up to more money than required, than also they are unable to buy the pizza. Each friend is guaranteed to have distinct amount of money. As it is Singham's world, money can also be negative ;).
Input
The first line consist of t (1 <= t <= 100) test cases. In the following 2*t lines, for each test case first there is n and m, where n (1 <= n <= 100000) is number of Singham's friend and m is the price of pizza. The next line consist of n integers, separated by space, which is the money each friend have.
The value of m and money is within the limits of int in C, C++.
Output
A single integer representing the number of pairs which can eat pizza.
Example
Input: 2 4 12 9 -3 4 3 5 -9 -7 3 -2 8 7 Output: 1 1
hide comments
ASHUTOSH DWIVEDI:
2015-07-16 19:28:54
AC in one go.......:) |
|
vasayashwanth:
2015-07-13 08:51:58
much similar to HACKRNDM just changed a sign + to - of that code and got accepted |
|
:.Mohib.::
2015-06-08 10:42:54
O(N) nice que.... :) |
|
Akshat Mathur:
2015-06-07 15:12:27
Similar to HACKRNDM. |
|
mukul arora:
2015-06-01 11:11:46
o(n*logn + n) would do! learnt something new |
|
Arafat dad Khan:
2015-05-25 20:13:31
Using maps gives TLE Strange!!! |
|
krish:
2015-04-27 19:13:59
@swami yes my AC solution gives 2 |
|
Aditya Kumar:
2015-03-24 18:47:46
Really liked it!
|
|
Nebojsa:
2015-03-18 22:53:31
AC in first go,simple logic! |
|
swami:
2015-03-04 18:59:13
what should be the answer for
|
Added by: | ! include(L.ppt) |
Date: | 2012-08-31 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | MNNIT OPC 31-08-2012 |