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

15234번 - Number Pairs 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB36529325480.635%

문제

Given a sequence of N distinct integer numbers compute the number of pairs that sum to K.

Example:

Given the sequence {1, 2, 3, 4, 5, 6}

  • There are 1 pair of numbers that sums to 3: (1, 2)
  • There are 1 pair of numbers that sums to 4: (3, 1)
  • There are 2 pairs of numbers that sum to 5: (1, 4) and (3, 2)
  • There are 2 pairs of numbers that sum to 6: (5, 1) and (4, 2)
  • There are 3 pairs of numbers that sum to 7: (1, 6), (2, 5) and (3, 4).
  • There are 2 pairs of numbers that sum to 8: (2, 6) and (5, 3)
  • There are 2 pairs of numbers that sum to 9: (6, 3) and (5, 4)
  • ...

Note that we consider that the pairs (1, 6) and (6, 1) are the same.

입력

The first line will contain two integers N and K.

N represents the number of elements in the sequence and K the goal value.

We want to know how many pairs of numbers sum to K.

The second line will contain N integers separated by spaces.

N <= 1000

The numbers in the sequence will be between 1 and 10^6.

출력

An integer, the number of pairs that add K.

제한

예제 입력 1

6 7
1 3 2 6 5 4

예제 출력 1

3

힌트

출처

Olympiad > All-Ireland Programming Olympiad > 2017 AIPO Preliminary Round 3번

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

출처

대학교 대회

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

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