Logo
(追記) (追記ここまで)

29940번 - Sum 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB23317010468.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$.

제한

예제 입력 1

5 10
1
3
5
7
9

예제 출력 1

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.

힌트

출처

Olympiad > Estonian Informatics Olympiad > 2018-19 > Preliminary Round 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /