Chess#7064

Chess

1 sekunt
32 megabaýt
Örän kyn

Petro Pyatochkin has recently developed a keen interest in chess. To familiarize himself with the strategies of renowned players, he decided to watch all the games from a friendly match between the capital's team and the team from the village of Velyki Olympiytsi.

Each player has a skill level, represented by a natural number. A player from one team can compete against a player from the other team if their skill levels differ by no more than — a specified non-negative integer. Each game involves one player from each team, and no player can participate in more than one game.

Petro wants to witness as many games as possible. To achieve this, he enlisted the help of a wizard to adjust the skill levels of all players on the village team by the same integer amount, maximizing the number of possible games. Note that after the adjustment, some players' skill levels might become negative.

Given the skill levels of all players and the value , determine:

Giriş

The first line of the input contains integers:

  • — the number of players on the village team (1 \le N \le 200);

  • — the number of players on the capital team (1 \le M \le 200);

  • — the maximum allowable difference in skill levels for players to compete (0 \le d \le 10^9).

All subsequent numbers are natural and do not exceed 10^9.

The second line contains numbers representing the skill levels of the village team players.

The third line contains numbers representing the skill levels of the capital team players.

Çykyş

The first line of the output should contain two integers: — the maximum number of games possible after the wizard's adjustment (even if no change is made) and — the adjustment amount for the village players' skill levels to achieve games.

The next lines should list unique pairs of natural numbers, one per line. Each pair consists of a player number from the village team and a player number from the capital team, respectively, who should compete to achieve a total of games. The pairs can be listed in any order.

Mysallar

1-nji mysal

Loading
Loading