아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Sum

시간 제한1초메모리 제한1024 MB

요약
정렬된 배열에서 두 원소의 합이 S인 쌍의 개수를 센다.
난이도

보통10점 중 4점

유형
투 포인터, 배열
정답자
아직 제출이 없습니다

문제

Consider an NN-element strictly increasing integer sequence AA and an integer SS.

Write a program to count the number of pairs of elements of AA whose sum is SS.

입력

The first line of input contains NN and SS, the length of the sequence and the required sum (1≤N≤100,0001 \le N \le 100\\,000, 0≤S≤2,000,0000 \le S \le 2\\,000\\,000). The following NN lines contain elements of the sequence, one element A_iA\_i (0≤A_i≤1,000,0000 \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 SS.

예제1

  1. 예제 1

    입력
    5 10
    1
    3
    5
    7
    9
    
    예상 출력
    2