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

32423번 - Doubles Horseback Wrestling 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB21111191.667%

문제

The Nomadic Games Exploratory Committee (NGEC) is floating the idea of a doubles horseback wrestling tournament with pairs of riders astride single horses. They have advertised a pilot tournament, and $n$ eager riders have signed up to compete! So now the NGEC needs to pair the riders in order to make the tournament both fair and exciting.

The Central Asian Audaryspak League (CAAL) maintains a list of all horseback wrestlers and their ratings. From their previous experience with ordinary horseback wrestling, the NGEC has decided that the pairs are best balanced if the ratings of their two riders add up to a particular integer, $s$.

For obscure licensing reasons, the CAAL refuses to release the exact rating of each rider. But the NGEC has some good estimates, knowing that any rider $i$’s true rating $r_i$ lies in an interval $[l_i, u_i]$. So the NGEC would consider pairing two riders $i$ and $j$ if there are ratings $r_i \in [l_i, u_i]$ and $r_j \in [l_j , u_j]$ such that $r_i + r_j = s$.

The NGEC wants to form as many non-intersecting pairs of riders as possible. You need to help them.

입력

The first line contains two integers $n$ and $s$ (2ドル ≤ n ≤ 2 \cdot 10^5,ドル 1ドル ≤ s ≤ 10^9$), denoting the number of riders and the desired sum of ratings of riders in a pair. Riders are numbered 1ドル$ to $n$. This is followed by $n$ lines, where the $i$th line contains two integers $l_i$ and $u_i$ (1ドル ≤ l_i ≤ u_i ≤ 10^9$), denoting the rating range of the $i$th rider.

출력

Output $k,ドル the maximum number of riding pairs that can be formed, followed by $k$ pairs of integers, denoting the numbers of the riders forming each pair. If there are multiple ways to pair off the riders, output any one.

제한

예제 입력 1

6 10
6 7
1 4
2 2
3 8
5 7
9 9

예제 출력 1

2
6 2
3 4

힌트

출처

ICPC > World Finals > ICPC World Finals 2024 D번

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

출처

대학교 대회

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

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