CF1329A.Dreamoon Likes Coloring
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Dreamoon likes coloring cells very much.
There is a row of n cells. Initially, all cells are empty (don't contain any color). Cells are numbered from 1 to n.
You are given an integer m and m integers l1,l2,…,lm (1≤li≤n)
Dreamoon will perform m operations.
In i-th operation, Dreamoon will choose a number pi from range [1,n−li+1] (inclusive) and will paint all cells from pi to pi+li−1 (inclusive) in i-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 m operations, all colors will appear at least once and all cells will be colored. Please help Dreamoon to choose pi in each operation to satisfy all constraints.
Dreamoon 非常喜欢给格子涂色。
有一排 n 个格子。初始时,所有格子均为空(即不包含任何颜色)。格子编号从 1 到 n。
你将得到一个整数 m 和 m 个整数 l1,l2,…,lm(满足 1≤li≤n)。
Dreamoon 将执行 m 次操作。
在第 i 次操作中,Dreamoon 将从区间 [1,n−li+1](含端点)中选择一个数 pi,并将从第 pi 个格子到第 pi+li−1 个格子(含端点)的所有格子涂上第 i 种颜色。注意:一个格子可能被多次涂色;若如此,该格子最终显示的是最后一次操作所涂的颜色。
Dreamoon 希望经过这 m 次操作后,每种颜色至少出现一次,且所有格子均被涂色(即没有空格子)。请帮助 Dreamoon 在每次操作中选择合适的 pi,以满足上述所有约束条件。
输入格式
The first line contains two integers n,m (1≤m≤n≤100000).
The second line contains m integers l1,l2,…,lm (1≤li≤n).
第一行包含两个整数 n,m(1≤m≤n≤100000)。
第二行包含 m 个整数 l1,l2,…,lm(1≤li≤n)。
输出格式
If it's impossible to perform m operations to satisfy all constraints, print "'-1" (without quotes).
Otherwise, print m integers p1,p2,…,pm (1≤pi≤n−li+1), after these m operations, all colors should appear at least once and all cells should be colored.
If there are several possible solutions, you can print any.
如果无法通过 m 次操作满足所有约束条件,则输出 "-1(不带引号)。
否则,输出 m 个整数 p1,p2,…,pm(其中 1≤pi≤n−li+1),使得经过这 m 次操作后,每种颜色至少出现一次,且所有格子均被染色。
若存在多种可行解,输出任意一种即可。
输入输出样例
输入#1
5 3 3 2 2
输出#1
2 4 1
输入#2
10 1 1
输出#2
-1
输入解题思路,AI测评打分。不知道怎么写?