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.

Input
The first line contains two integers n,m (1≤m≤n≤100000).

The second line contains m integers l1,l2,…,lm (1≤li≤n).

Output
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.

Examples

input
5 3
3 2 2
output
2 4 1
input
10 1
1
output
-1
#include <bits/stdc++.h>#define ll long long
using namespace std;
const int N = 1e5 + 10;
int ans[N], l[N], n, m;
ll sum;int main() {cin >> n >> m;for (int i = 1; i <= m; i++)scanf("%d", &l[i]), sum += l[i];if (sum < n) {puts("-1");return 0;}for (int i = 1; i <= m; i++)if (n - l[i] + 1 < i) {puts("-1");return 0;}ll rec = sum - n;int now = 1;for (int i = 1; i <= m; i++) {ans[i] = now;int res = min(rec, 1ll * l[i] - 1);rec -= res;now = now + l[i] - res;}for (int i = 1; i <= m; i++)printf("%d ", ans[i]);return 0;
}

Dreamoon Likes Coloring相关推荐

  1. Dreamoon Likes Coloring CodeForces - 1330C(贪心+思维)

    Dreamoon likes coloring cells very much. There is a row of n cells. Initially, all cells are empty ( ...

  2. Codeforces Round #631 (Div. 2) C. Dreamoon Likes Coloring 构造

    传送门 文章目录 题意: 思路: 题意: 思路: 针灸思维不行,数据结构来凑呗. 一开始做的时候想简单了,一直wawawa,后来想到了hackhackhack样例,开始换思路构造,结果死活想不到O(m ...

  3. Dreamoon Likes Sequences CodeForces - 1330D(组合数学+位运算)

    Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find i ...

  4. Codeforces Round #631 (Div. 2) D. Dreamoon Likes Sequences 思维 + 组合数学

    传送门 文章目录 题意: 思路: 题意: 给你d,modd,modd,mod,让你求能构造出如下序列aaa的个数模modmodmod: 思路: 首先可以发现aaa的长度不能超过log2dlog_2dl ...

  5. CodeForces - 1330D Dreamoon Likes Sequences(组合数学)

    题目链接:点击查看 题目大意:给出一个限制 d 与模数 mod ,求出可以构造出的满足条件的数组 a 的个数,需要满足以下条件: 数组 a 的长度大于等于 1 数组 a 严格递增 数组 a 的最小值大 ...

  6. D. Dreamoon Likes Sequences(异或)

    Problem - 1330D - Codeforces 题意: 给你两个整数d,m,找出数组a的数量,满足以下约束. a的长度为n,n≥1 1≤a1<a2<⋯<an≤d 定义长度为 ...

  7. szu cf集训Codeforces Round #631 (Div. 2)A ~ D[贪心,数据结构,思维,dp]

    A. Dreamoon and Ranking Collection 题意:题意不太好理解.简单来讲就是,给出一组数,能从1最多数到几,不够的用数来填,最多填x次.思路:代码很简单-先出现过的地方肯定 ...

  8. 【11.9】Codeforces 刷题

    DP\text{DP}DP : B. Yaroslav and Two Strings 题意: 如果两个只包含数字且长度为 n(1≤n≤105)n(1\leq n\leq 10^5)n(1≤n≤105 ...

  9. android xlintdeprecation 重新编译,天博体育官网-官网首页

    PC Flutter 裁剪布局之 ClipRect.ClipRRect.ClipOval.ClipPath.CustomClipper. 斯坦福大学公开课机器学习:Neural network-mod ...

  10. Codeforces Round #272 (Div. 2)

    链接 : http://codeforces.com/contest/476 D题yy,ABC水 A. Dreamoon and Stairs time limit per test 1 second ...

最新文章

  1. VS2010 自定义用户控件未出现在工具箱的解决方案
  2. Qt窗口部件与布局之二:布局管理
  3. 浏览器为什么会有兼容性问题
  4. 高性能SQLServer通用分页存储过程
  5. Widget开发中遇到的坑
  6. uni-app目录结构介绍
  7. python读数据小数点_将excel数据读入pandas dataframe,精确到小数点后20位
  8. Linux scp 使用详解
  9. 查看编译class文件时,使用的JDK版本(只能查看到大版本)
  10. Spring Boot 集成undertow作为web容器分析
  11. Android事件分发机制综述
  12. 阿里云商标注册申请智能、顾问和安心区别及选择攻略
  13. 中小型企业应该选择什么样的OA系统?
  14. php导出数据库为excel文件,phpexcel导出数据库成excel文件
  15. 没有免费午餐定理No Free Lunch Theorem
  16. mysql mmm 测试_mysql-mmm有关mmm_control 参数测试
  17. 计算机三级网络技术最全知识点总结一
  18. Android百度地图显示附近的位置
  19. m4r格式转换器免费版 V3.0
  20. safari下载文件_如何更改Safari下载文件夹的位置

热门文章

  1. python小玩具(恶俗古风生成器)
  2. 2022年重庆医院三基考试心血管系统疾病多选练习题及答案
  3. PS176替代方案| DP转HDMI2.0音视频转换芯片CS5263
  4. 含泪整理最优质鲜肉VRay材质球素材,你想要的这里都有
  5. React Hook介绍(二):Effect Hook
  6. qt中如何模拟按钮点击_qt模拟鼠标单击事件
  7. 华为ensp模拟企业网(校园网),总分公司(总分校区),多区域互联,代码有详细注释
  8. 运动无线耳机推荐,六款运动爱好者必备的耳机
  9. mongoDB 4.0 开启远程访问
  10. 动态路由协议之OSPF基本原理、区域划分及配置