CF1329A.Dreamoon Likes Coloring

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Dreamoon likes coloring cells very much.

There is a row of nn cells. Initially, all cells are empty (don't contain any color). Cells are numbered from 11 to nn.

You are given an integer mm and mm integers l1,l2,…,lml_1, l_2, \ldots, l_m (1≤li≤n1 \le l_i \le n)

Dreamoon will perform mm operations.

In ii-th operation, Dreamoon will choose a number pip_i from range [1,n−li+1][1, n-l_i+1] (inclusive) and will paint all cells from pip_i to pi+li−1p_i+l_i-1 (inclusive) in ii-th color. Note that cells may be colored more one than once, in this case, cell will have the color from the latest operation.

Dreamoon hopes that after these mm operations, all colors will appear at least once and all cells will be colored. Please help Dreamoon to choose pip_i in each operation to satisfy all constraints.

Dreamoon 非常喜欢给格子涂色。

有一排 nn 个格子。初始时,所有格子均为空(即不包含任何颜色)。格子编号从 11 到 nn。

你将得到一个整数 mm 和 mm 个整数 l1,l2,…,lml_1, l_2, \ldots, l_m(满足 1≤li≤n1 \le l_i \le n)。

Dreamoon 将执行 mm 次操作。

在第 ii 次操作中,Dreamoon 将从区间 [1,n−li+1][1, n-l_i+1](含端点)中选择一个数 pip_i,并将从第 pip_i 个格子到第 pi+li−1p_i+l_i-1 个格子(含端点)的所有格子涂上第 ii 种颜色。注意:一个格子可能被多次涂色;若如此,该格子最终显示的是最后一次操作所涂的颜色。

Dreamoon 希望经过这 mm 次操作后,每种颜色至少出现一次,且所有格子均被涂色(即没有空格子)。请帮助 Dreamoon 在每次操作中选择合适的 pip_i,以满足上述所有约束条件。

输入格式

The first line contains two integers n,mn,m (1≤m≤n≤100 0001 \leq m \leq n \leq 100\,000).

The second line contains mm integers l1,l2,…,lml_1, l_2, \ldots, l_m (1≤li≤n1 \leq l_i \leq n).

第一行包含两个整数 n,mn,m(1≤m≤n≤100 0001 \leq m \leq n \leq 100\,000)。

第二行包含 mm 个整数 l1,l2,…,lml_1, l_2, \ldots, l_m(1≤li≤n1 \leq l_i \leq n)。

输出格式

If it's impossible to perform mm operations to satisfy all constraints, print "'-1" (without quotes).

Otherwise, print mm integers p1,p2,…,pmp_1, p_2, \ldots, p_m (1≤pi≤n−li+11 \leq p_i \leq n - l_i + 1), after these mm operations, all colors should appear at least once and all cells should be colored.

If there are several possible solutions, you can print any.

如果无法通过 mm 次操作满足所有约束条件,则输出 "-1(不带引号)。

否则,输出 mm 个整数 p1,p2,…,pmp_1, p_2, \ldots, p_m(其中 1≤pi≤n−li+11 \leq p_i \leq n - l_i + 1),使得经过这 mm 次操作后,每种颜色至少出现一次,且所有格子均被染色。

若存在多种可行解,输出任意一种即可。

输入输出样例

  • 输入#1

    5 3
    3 2 2

    输出#1

    2 4 1
  • 输入#2

    10 1
    1

    输出#2

    -1

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

首页