Doubles Horseback Wrestling
면접 대비시간 제한4초메모리 제한1024 MB
각 선수의 레이팅 구간이 주어질 때 두 레이팅 합이 s가 되도록 짝을 지어, 겹치지 않는 짝의 수를 최대로 만든다.
문제
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 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, .
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 ’s true rating lies in an interval . So the NGEC would consider pairing two riders and if there are ratings and such that .
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 and (, ), denoting the number of riders and the desired sum of ratings of riders in a pair. Riders are numbered to . This is followed by lines, where the th line contains two integers and (), denoting the rating range of the th rider.
출력
Output , the maximum number of riding pairs that can be formed, followed by 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.