#GD0000141. Nhảy qua các bệ trên sông (Platforms Jumping)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Nhảy qua các bệ trên sông (Platforms Jumping)
Platforms Jumping
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A river has cells numbered from to , with banks at and . There are wooden platforms, and platform must occupy exactly consecutive cells. Platforms may be moved before the crossing, but cannot overlap and must remain in their original order.
From the current position the traveler may jump forward by at most cells and land only on a platform or a bank. Determine whether the platforms can be arranged to cross the river. If possible, output a valid arrangement.
Input
The first line contains . The second line contains integers , the platform lengths.
Output
Print NO if no arrangement is possible. Otherwise print YES and a line of integers: for water, or the -based index of the platform covering that cell. Each platform must occupy exactly one contiguous run of its required length in the original order.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
7 3 2
1 2 1
Output
YES
0 1 0 2 2 0 3
Explanation
There are four wooden cells and three water cells. One valid arrangement puts the platforms at cells , –, and . Jumps all have length at most .