Card Game | 프로그래밍의 벗 PivotOJ
PivotOJ

Card Game

시간 제한: 3000ms메모리 제한: 2048MB출처: EIO 2023-24 sel2BOJ 33133

문제

Vilius and Adomas play a simple card game. They have a deck of NN 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 CC and wants to win by exactly CC points. In other words, he wants the sum of his cards minus the sum of Adomas's cards to be exactly CC. How many ways there are for Vilius and Adomas to draw their cards so that Vilius wins by exactly CC 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 11 and three cards contain the number 22, there would be six ways for Adomas to draw cards with numbers 11 and 22.

입력

The first line contains two integers NN and CC (4N15004 \le N \le 1\,500, 0C1090 \le C \le 10^9), the number of cards in the deck and the desired score difference, respectively. The second line contains NN integers A1,A2,,ANA_1, A_2, \ldots, A_N (0Ai1090 \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 CC points.

예제

예제 1

입력
5 3
1 3 4 5 6
출력
2

예제 2

입력
5 0
2 2 2 2 2
출력
30
코드를 제출하려면 로그인하세요.