logo AlgoBeat OnlineJudge
登录 注册

#212885. [NERC 2021] Even Split

内存限制:512 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

A revolution has recently happened in Segmentland. The new government is committed to equality, and they hired you to help with land redistribution in the country.

Segmentland is a segment of length kilometers, with the capital in one of its ends. There are citizens in Segmentland, the home of -th citizen is located at the point kilometers from the capital. No two homes are located at the same point. Each citizen should receive a segment of positive length with ends at integer distances from the capital that contains her home. The union of these segments should be the whole of Segmentland, and they should not have common points besides their ends. To ensure equality, the difference between the lengths of the longest and the shortest segments should be as small as possible.

输入格式

The first line of the input contains two integers and ().

The second line contains integers ().

输出格式

Output pairs of numbers (), one pair per line. The pair on -th line denotes the~ends of the segment that -th citizen receives.

If there are many possible arrangements with the same difference between the lengths of the longest and the shortest segments, you can output any of them.

样例

样例输入 1

6 3
1 3 5

样例输出 1

0 2
2 4
4 6

样例输入 2

10 2
1 2

样例输出 2

0 2
2 10

数据范围与提示

In the first example, it is possible to make all segments equal.

In the second example, citizens live close to the capital, so the length of the shortest segment is 2 and the length of the longest segment is 8.