PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000141. Nhảy qua các bệ trên sông (Platforms Jumping)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

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 nn cells numbered from 11 to nn, with banks at 00 and n+1n+1. There are mm wooden platforms, and platform ii must occupy exactly cic_i 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 dd 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 n,m,dn,m,d. The second line contains mm integers c1,…,cmc_1,\ldots,c_m, the platform lengths.

Output

Print NO if no arrangement is possible. Otherwise print YES and a line of nn integers: 00 for water, or the 11-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): 1≤n,m,d≤161\le n,m,d\le16; m≤nm\le n; 1≤ci≤n1\le c_i\le n; ∑ci≤n\sum c_i\le n.
  • Subtask 2 (30 points): 1≤n,m,d≤1501\le n,m,d\le150; m≤nm\le n; 1≤ci≤n1\le c_i\le n; ∑ci≤n\sum c_i\le n.
  • Subtask 3 (50 points): 1≤n,m,d≤10001\le n,m,d\le1000; m≤nm\le n; 1≤ci≤n1\le c_i\le n; ∑ci≤n\sum c_i\le n.

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 22, 44–55, and 77. Jumps 0→2→4→5→7→80\to2\to4\to5\to7\to8 all have length at most 22.