Số cặp
View as PDF
Submit solution
Points:
0.10 (partial)
Time limit:
1.0s
Memory limit:
64M
Input:
stdin
Output:
stdout
Author:
Problem type
Cho mảng ~A~ gồm ~n~ phần tử nguyên phân biệt được sắp xếp theo thứ tự tăng dần. Hãy đếm số lượng cặp chỉ số ~(i, j)~ với ~i < j~ sao cho ~A_i + A_j = x~.
Input
- Dòng đầu chứa hai số nguyên ~n~, ~x~ ~(1 \le n \le 10^5)~, ~(1 \le A_i, x \le 10^9)~.
- Dòng thứ hai chứa ~n~ số nguyên phân biệt ~A_i~, sắp xếp theo thứ tự tăng dần.
Output
- Một số nguyên duy nhất — số lượng cặp ~(i, j)~ thoả mãn điều kiện.
Ví dụ
Input
5 6
1 2 3 4 5
Output
2
Comments