Racing Strategy | 프로그래밍의 벗 PivotOJ
PivotOJ

Racing Strategy

시간 제한: 1000ms메모리 제한: 1024MB출처: EIO 2021-22 openBOJ 29850

문제

Erika Isabella Orav is a driver in the Celsius MotoSport team of the FI (Formula Informatics) racing series. There's a new race coming up and the weather forecast is good. The team has trained hard to hone their pit stop skills, but need help figuring out the best strategy.

The upcoming race consists of NN laps. The team can use MM types of tyres with different rubber compositions. The rubber composition of a tyre determines its grip (which affects how fast the car can go) and its wear (which affects how fast the tyre deteriorates). There is unlimited amount of tyres of each type available.

When the race starts, the team's chosen tyres are already installed on the car (no pit stop needed). During the race, the driver may go to a pit stop after any lap and have the current tyres replaced with a fresh set of any type. Based on their practice, the team knows a pit stop takes them KK seconds.

Celsius MotoSport has carefully analysed the available tyres and determined for each type ii two parameters:

  • PiP_i --- the number of seconds it takes to drive the first lap with tyres of this type;
  • WiW_i --- the number of seconds by which each following lap is slower than the previous one.

Help the team find an optimal pit stop strategy to complete the race in the shortest time possible.

입력

The first line contains three space-separated integers MM (1M5001 \le M \le 500), NN (1N2001 \le N \le 200), and KK (1K10001 \le K \le 1\,000). Each of the following MM lines describes one tyre type: two space-separated integers PiP_i (1Pi10001 \le P_i \le 1\,000) and WiW_i (0Wi10000 \le W_i \le 1\,000). The tyre types are numbered 1,,M1, \ldots, M in their order in the input.

출력

The first line should contain two space-separated integers, i0i_0 and BB---the type of tyres to install for the start of the race and the number of pit stops, respectively. Each of the following BB lines should describe one pit stop as two integers---the number of the lap after which to make the stop (the laps are numbered 1,,N1, \ldots, N) and the type of the new tyres to install on the car. The pit stops should be listed in chronological order. If there are several optimal strategies, output any one of them.

예제

예제 1

입력
2 2 25
45 11
40 20
출력
2 0

예제 2

입력
2 44 170
60 8
30 29
출력
1 6
6 1
12 1
18 1
24 1
30 1
37 1

예제 3

입력
3 1 25
45 10
40 20
55 10
출력
2 0
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.