CF1329A.Dreamoon Likes Coloring

普及/提高-

通过率:0%

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 ( 1lin1 \le l_i \le n )

Dreamoon will perform mm operations.

In ii -th operation, Dreamoon will choose a number pip_i from range [1,nli+1][1, n-l_i+1] (inclusive) and will paint all cells from pip_i to pi+li1p_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.

输入格式

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

The second line contains mm integers l1,l2,,lml_1, l_2, \ldots, l_m ( 1lin1 \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 ( 1pinli+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.

输入输出样例

  • 输入#1

    5 3
    3 2 2

    输出#1

    2 4 1
  • 输入#2

    10 1
    1

    输出#2

    -1
首页