P26961 [AtCoder] Buffalo
NOI
题目描述

Problem Description

There are $ N $ containers, and the $ i $th container can hold $ A_i $ liters of water.

Ushiku wants to choose 2 containers from the $ N $ containers and perform the following operations any number of times to achieve a state where the 2 containers together hold a total of $ K $ liters of water.

  • Operation $ 1 $: Fill one container to the brim with water.
  • Operation $ 2 $: Transfer water from container $ X $ to another container $ Y $ until $ Y $ is full or $ X $ is empty.
  • Operation $ 3 $: Discard all the water from one container.

Determine the number of ways to choose pairs of containers such that $ K $ liters of water can be drawn using the above methods.

Note that initially, all containers are empty, and it is acceptable not to use one of the chosen containers at all.

Input Format

The input is given from the standard input in the following format:

$ N $ $ K $ $ A_1 $ $ A_2 $ $ ... $ $ A_N $

Output Format

Output the answer in one line.

Sample Input and Output

Sample Input #1

2 3
4 7

Sample Output #1

1

Sample Input #2

3 11
5 6 11

Sample Output #2

3

Sample Input #3

3 10
3 4 5

Sample Output #3

0

Notes/Hints

Constraints

  • $2 \leq N \leq 3 \times 10^5$
  • $1 \leq K \leq 2 \times 10^6$
  • $1 \leq A_i \leq 10^6$
  • All inputs are integers

Sample Explanation 1

Using the 1st and 2nd containers, the following operations can draw 3 liters of water:
- Fill the 2nd container to the brim.
- Transfer water from the 2nd container to the 1st container until the 1st container is full.
- Discard all the water from the 1st container.

Sample Explanation 2

Any pair can draw 11 liters of water.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 3 4 7
样例输出
1