| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 | 2048 MB | 31 | 9 | 6 | 35.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.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 9 | All cards have the same number. |
| 2 | 19 | $N \le 100$. |
| 3 | 24 | $N \le 400$. |
| 4 | 19 | $1 \le A_i \le 50$ for all $1 \le i \le N$. |
| 5 | 29 | No additional constraints. |
5 3 1 3 4 5 6
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$.
5 0 2 2 2 2 2
30
All ways to draw the cards work.