Zonal Computing Olympiad 2013, 10 Nov 2012

2:00 pm-5:00 pm IST

Problem 1: Chewing

Hobbes has challenged Calvin to display his chewing skills and chew two different types of Chewing Magazine's Diabolic Jawlockers chewing gum at the same time. Being a generous sort of tiger, Hobbes allows Calvin to pick the two types of gum he will chew.

Each type of chewing gum has a hardness quotient, given by a non-negative integer. If Calvin chews two pieces of gum at the same time, the total hardness quotient is the sum of the individual hardness quotients of the two pieces of gum.

Calvin knows that he cannot chew any gum combination whose hardness quotient is K or more. He is given a list with the hardness quotient of each type of gum in the Diabolic Jawlockers collection. How many different pairs of chewing gum can Calvin choose from so that the total hardness quotient remains strictly below his hardness limit K?

For instance, suppose there are 7 types of chewing gum as follows:

 Chewing gum type   1   2   3   4   5   6   7 
 Hardness quotient   10   1   3   1   5   5   0 

If Calvin's hardness limit is 4, there are 4 possible pairs he can choose: type 2 and 7 (1+0 < 4), type 3 and 7 (3+0 < 4), type 2 and 4 (1+1 < 4) and type 4 and 7 (1+0 < 4).

Input format

Line 1 : Two space separated integers N and K, where N is the number of different types of chewing gum and K is Calvin's hardness limit.

Line 2: N space separated non-negative integers, which are the hardness quotients of each of the N types of chewing gum.

Output format

The output consists of a single non-negative integer, the number of pairs of chewing gum with total hardness quotient strictly less than K.

Sample Input

7 4
10 1 3 1 5 5 0

Sample Output

4

Test data

In all subtasks, you may assume that all the hardness quotients as well as the hardness limit K are between 0 and 1,000,000, inclusive.

Subtask 1 (30 marks) : 2 ≤ N ≤ 2,000.

Subtask 2 (70 marks) : 2 ≤ N ≤ 100,000.

Limits

Time limit : 3s

Memory limit: 64 MB

Note

The answer might not fit in a variable of type int. We recommend that type long long be used for computing the answer. If you use printf and scanf, you can use %lld for long long.




Copyright (c) IARCS 2003-2024;   Last Updated: 23 Sep 2012