| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 233 | 170 | 104 | 68.874% |
Consider an $N$-element strictly increasing integer sequence $A$ and an integer $S$.
Write a program to count the number of pairs of elements of $A$ whose sum is $S$.
The first line of input contains $N$ and $S,ドル the length of the sequence and the required sum (1ドル \le N \le 100,000円,ドル 0ドル \le S \le 2,000円,000円$). The following $N$ lines contain elements of the sequence, one element $A_i$ (0ドル \le A_i \le 1,000円,000円$) on each line. The elements are distinct and ordered increasingly.
The only line of output should contain the number of pairs that consist of two distinct elemets of the sequence and sum to $S$.
5 10 1 3 5 7 9
2
The elements of the sequence are $A_1 = 1,ドル $A_2 = 3,ドル $A_3 = 5,ドル $A_4 = 7,ドル and $A_5 = 9$. There are two pairs that sum to 10ドル$: $A_1 + A_5 = 1 + 9 = 10$ and $A_2 + A_4 = 3 + 7 = 10$. Note that $A_3 + A_3 = 5 + 5 = 10$ is not counted, as it is not a sum of two distinct elements. $A_4 + A_2 = 7 + 3 = 10$ and $A_5 + A_1 = 9 + 1 = 10$ are also excluded, as they have already been counted.