306823: CF1256C. Platforms Jumping

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Platforms Jumping

题意翻译

## 题目描述 有一条宽度为$n$的河。河的左岸编号为$0$,右岸编号为$n + 1$。河流上还有$m$个木制平台,第$i$个平台的长度为$ci$(所以说第i个平台占据河流的$ci$个连续位置)。保证平台长度的总和不超过n。 你正站在$0$(左岸),并且想到达右岸即$n + 1$的位置。如果您站在位置x,则可以跳到$[x + 1; x + d]$范围内的任何位置。但是, 你只能跳到木质平台上( _即不能下水_ )。例如,如果$d = 1$,则只能跳到下一个位置(如果这个位置上有木制平台)。您可以假设单元格$0$和$n + 1$属于木制平台。 您可以将任意平台向左或向右移动任意次数(也可以不移动),只要它们彼此不重叠(但两个平台可以挨在一起)。也就是说你不能更改平台的相对顺序。 **请注意,你应该先移动平台再跳跃(一旦你出发后,你就不能再移动平台了)。** 例如,如果$n = 7$,$m = 3$,$d = 2$和$c = [1,2,1]$,这就是从左岸跳到右岸的方法之一: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1256C/df0d8d2f8a9c6cd940b3eabc79499fe8d2091270.png) ## 输入格式 输入的第一行包含三个整数$n$,$m$和$d$($1≤n$,$m,d≤1000$,$m≤n$) 输入的第二行包含m个整数$c1,c2,…,cm$($1≤ci≤n$,$\sum_{i=1}^mci$ ≤ $n$ _【这里打的和原题面格式不太一样,就是说木平台的长度和不大于河宽】_ ),其中ci是第i个平台的长度。 ## 输出格式 如果不可能从0达到n + 1,则在第一行中输出"NO"。否则,在第一行中打印“YES”,在第二行中输出长度为n的数组 输出河流的序列(不输出单元格0和单元格n + 1)。 如果河流单元格i不属于任何平台,输出0。否则,它应该是等于平台的编号(平台编号是从1到m输入的顺序)。

题目描述

There is a river of width $ n $ . The left bank of the river is cell $ 0 $ and the right bank is cell $ n + 1 $ (more formally, the river can be represented as a sequence of $ n + 2 $ cells numbered from $ 0 $ to $ n + 1 $ ). There are also $ m $ wooden platforms on a river, the $ i $ -th platform has length $ c_i $ (so the $ i $ -th platform takes $ c_i $ consecutive cells of the river). It is guaranteed that the sum of lengths of platforms does not exceed $ n $ . You are standing at $ 0 $ and want to reach $ n+1 $ somehow. If you are standing at the position $ x $ , you can jump to any position in the range $ [x + 1; x + d] $ . However you don't really like the water so you can jump only to such cells that belong to some wooden platform. For example, if $ d=1 $ , you can jump only to the next position (if it belongs to the wooden platform). You can assume that cells $ 0 $ and $ n+1 $ belong to wooden platforms. You want to know if it is possible to reach $ n+1 $ from $ 0 $ if you can move any platform to the left or to the right arbitrary number of times (possibly, zero) as long as they do not intersect each other (but two platforms can touch each other). It also means that you cannot change the relative order of platforms. Note that you should move platforms until you start jumping (in other words, you first move the platforms and then start jumping). For example, if $ n=7 $ , $ m=3 $ , $ d=2 $ and $ c = [1, 2, 1] $ , then one of the ways to reach $ 8 $ from $ 0 $ is follow: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1256C/df0d8d2f8a9c6cd940b3eabc79499fe8d2091270.png)The first example: $ n=7 $ .

输入输出格式

输入格式


The first line of the input contains three integers $ n $ , $ m $ and $ d $ ( $ 1 \le n, m, d \le 1000, m \le n $ ) — the width of the river, the number of platforms and the maximum distance of your jump, correspondingly. The second line of the input contains $ m $ integers $ c_1, c_2, \dots, c_m $ ( $ 1 \le c_i \le n, \sum\limits_{i=1}^{m} c_i \le n $ ), where $ c_i $ is the length of the $ i $ -th platform.

输出格式


If it is impossible to reach $ n+1 $ from $ 0 $ , print NO in the first line. Otherwise, print YES in the first line and the array $ a $ of length $ n $ in the second line — the sequence of river cells (excluding cell $ 0 $ and cell $ n + 1 $ ). If the cell $ i $ does not belong to any platform, $ a_i $ should be $ 0 $ . Otherwise, it should be equal to the index of the platform ( $ 1 $ -indexed, platforms are numbered from $ 1 $ to $ m $ in order of input) to which the cell $ i $ belongs. Note that all $ a_i $ equal to $ 1 $ should form a contiguous subsegment of the array $ a $ of length $ c_1 $ , all $ a_i $ equal to $ 2 $ should form a contiguous subsegment of the array $ a $ of length $ c_2 $ , ..., all $ a_i $ equal to $ m $ should form a contiguous subsegment of the array $ a $ of length $ c_m $ . The leftmost position of $ 2 $ in $ a $ should be greater than the rightmost position of $ 1 $ , the leftmost position of $ 3 $ in $ a $ should be greater than the rightmost position of $ 2 $ , ..., the leftmost position of $ m $ in $ a $ should be greater than the rightmost position of $ m-1 $ . See example outputs for better understanding.

输入输出样例

输入样例 #1

7 3 2
1 2 1

输出样例 #1

YES
0 1 0 2 2 0 3 

输入样例 #2

10 1 11
1

输出样例 #2

YES
0 0 0 0 0 0 0 0 0 1 

输入样例 #3

10 1 5
2

输出样例 #3

YES
0 0 0 0 1 1 0 0 0 0 

说明

Consider the first example: the answer is $ [0, 1, 0, 2, 2, 0, 3] $ . The sequence of jumps you perform is $ 0 \rightarrow 2 \rightarrow 4 \rightarrow 5 \rightarrow 7 \rightarrow 8 $ . Consider the second example: it does not matter how to place the platform because you always can jump from $ 0 $ to $ 11 $ . Consider the third example: the answer is $ [0, 0, 0, 0, 1, 1, 0, 0, 0, 0] $ . The sequence of jumps you perform is $ 0 \rightarrow 5 \rightarrow 6 \rightarrow 11 $ .

Input

题意翻译

## 题目描述 有一条宽度为$n$的河。河的左岸编号为$0$,右岸编号为$n + 1$。河流上还有$m$个木制平台,第$i$个平台的长度为$ci$(所以说第i个平台占据河流的$ci$个连续位置)。保证平台长度的总和不超过n。 你正站在$0$(左岸),并且想到达右岸即$n + 1$的位置。如果您站在位置x,则可以跳到$[x + 1; x + d]$范围内的任何位置。但是, 你只能跳到木质平台上( _即不能下水_ )。例如,如果$d = 1$,则只能跳到下一个位置(如果这个位置上有木制平台)。您可以假设单元格$0$和$n + 1$属于木制平台。 您可以将任意平台向左或向右移动任意次数(也可以不移动),只要它们彼此不重叠(但两个平台可以挨在一起)。也就是说你不能更改平台的相对顺序。 **请注意,你应该先移动平台再跳跃(一旦你出发后,你就不能再移动平台了)。** 例如,如果$n = 7$,$m = 3$,$d = 2$和$c = [1,2,1]$,这就是从左岸跳到右岸的方法之一: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1256C/df0d8d2f8a9c6cd940b3eabc79499fe8d2091270.png) ## 输入格式 输入的第一行包含三个整数$n$,$m$和$d$($1≤n$,$m,d≤1000$,$m≤n$) 输入的第二行包含m个整数$c1,c2,…,cm$($1≤ci≤n$,$\sum_{i=1}^mci$ ≤ $n$ _【这里打的和原题面格式不太一样,就是说木平台的长度和不大于河宽】_ ),其中ci是第i个平台的长度。 ## 输出格式 如果不可能从0达到n + 1,则在第一行中输出"NO"。否则,在第一行中打印“YES”,在第二行中输出长度为n的数组 输出河流的序列(不输出单元格0和单元格n + 1)。 如果河流单元格i不属于任何平台,输出0。否则,它应该是等于平台的编号(平台编号是从1到m输入的顺序)。

加入题单

上一题 下一题 算法标签: