CF1666E.Even Split

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 ll kilometers, with the capital in one of its ends. There are nn citizens in Segmentland, the home of ii-th citizen is located at the point aia_i 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.

Segmentland 近期发生了一场革命。新政府致力于实现平等,因此聘请你协助该国进行土地再分配。

Segmentland 是一条长度为 ll 千米的线段,其首都位于该线段的一个端点处。Segmentland 共有 nn 位公民,其中第 ii 位公民的住所位于距首都 aia_i 千米处。任意两位公民的住所均不重合(即所有 aia_i 互不相等)。每位公民应分得一段长度为正数的线段,该线段的两个端点必须位于距首都整数千米的位置,且必须包含该公民的住所。这些线段的并集必须恰好覆盖整个 Segmentland,且任意两线段除端点外不得有其他公共点。为确保平等,最长线段与最短线段的长度之差应尽可能小。

输入格式

The first line of the input contains two integers ll and nn (2≤l≤109;1≤n≤1052 \leq l \leq 10^9; 1 \leq n \leq 10^5).

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (0<a1<a2<⋯<an<l0 \lt a_1 \lt a_2 \lt \dots \lt a_n \lt l).

输入的第一行包含两个整数 ll 和 nn(2≤l≤1092 \leq l \leq 10^9;1≤n≤1051 \leq n \leq 10^5)。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(0<a1<a2<⋯<an<l0 \lt a_1 \lt a_2 \lt \dots \lt a_n \lt l)。

输出格式

Output nn pairs of numbers si,fis_i, f_i (0≤si<fi≤l0 \leq s_i \lt f_i \leq l), one pair per line. The pair on ii-th line denotes the ends of the [si,fi][s_i, f_i] segment that ii-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.

输出 nn 对数字 si,fis_i, f_i(满足 0≤si<fi≤l0 \leq s_i \lt f_i \leq l),每行一对。第 ii 行的数对表示第 ii 位市民所获得的区间 [si,fi][s_i, f_i] 的两个端点。

若存在多种安排方式使得最长区间与最短区间的长度之差相同,则可任选其中一种输出。

输入输出样例

  • 输入#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. Viva la revolucion!

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.

在第一个例子中,可以使所有线段长度相等。革命万岁!

在第二个例子中,市民居住地离首都较近,因此最短线段的长度为 2,最长线段的长度为 8。

输入解题思路,AI测评打分。不知道怎么写?

首页