CF1329A.Dreamoon Likes Coloring
普及/提高-
通过率:0%
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.
输入格式
The first line contains two integers n,m ( 1≤m≤n≤100000 ).
The second line contains m integers 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.
输入输出样例
输入#1
5 3 3 2 2
输出#1
2 4 1
输入#2
10 1 1
输出#2
-1