시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB319635.294%

문제

Vilius and Adomas play a simple card game. They have a deck of $N$ cards. Every card contains a number. Each player draws two random cards from the deck, adds the two numbers on the cards, and the player with the larger sum wins.

Vilius chose a number $C$ and wants to win by exactly $C$ points. In other words, he wants the sum of his cards minus the sum of Adomas's cards to be exactly $C$. How many ways there are for Vilius and Adomas to draw their cards so that Vilius wins by exactly $C$ points?

The same number can be written on multiple cards. Then the case when a player draws one or another of them are considered distinct. The order of the two cards in a player's hand, however, does not matter. For example, if two cards contain the number $1$ and three cards contain the number $2$, there would be six ways for Adomas to draw cards with numbers $1$ and $2$.

입력

The first line contains two integers $N$ and $C$ ($4 \le N \le 1\,500$, $0 \le C \le 10^9$), the number of cards in the deck and the desired score difference, respectively. The second line contains $N$ integers $A_1, A_2, \ldots, A_N$ ($0 \le A_i \le 10^9$), the numbers on the cards.

출력

Output a single integer: the number of ways the players can draw cards so that Vilius wins by exactly $C$ points.

서브태스크

번호배점제한
19

All cards have the same number.

219

$N \le 100$.

324

$N \le 400$.

419

$1 \le A_i \le 50$ for all $1 \le i \le N$.

529

No additional constraints.

예제 입력 1

5 3
1 3 4 5 6

예제 출력 1

2

There are $2$ ways Vilius can win by $3$ points: when he draws $3$ and $5$ while Adomas draws $1$ and $4$, or when he draws $3$ and $6$ while Adomas draws $1$ and $5$.

예제 입력 2

5 0
2 2 2 2 2

예제 출력 2

30

All ways to draw the cards work.

채점 및 기타 정보

  • 예제는 채점하지 않는다.