CF509B.Painting Pebbles

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn piles of pebbles on the table, the ii -th pile contains aia_{i} pebbles. Your task is to paint each pebble using one of the kk given colors so that for each color cc and any two piles ii and jj the difference between the number of pebbles of color cc in pile ii and number of pebbles of color cc in pile jj is at most one.

In other words, let's say that bi,cb_{i,c} is the number of pebbles of color cc in the ii -th pile. Then for any 1<=c<=k1<=c<=k , 1<=i,j<=n1<=i,j<=n the following condition must be satisfied bi,cbj,c<=1|b_{i,c}-b_{j,c}|<=1 . It isn't necessary to use all kk colors: if color cc hasn't been used in pile ii , then bi,cb_{i,c} is considered to be zero.

输入格式

The first line of the input contains positive integers nn and kk ( 1<=n,k<=1001<=n,k<=100 ), separated by a space — the number of piles and the number of colors respectively.

The second line contains nn positive integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=1001<=a_{i}<=100 ) denoting number of pebbles in each of the piles.

输出格式

If there is no way to paint the pebbles satisfying the given condition, output "NO" (without quotes) .

Otherwise in the first line output "YES" (without quotes). Then nn lines should follow, the ii -th of them should contain aia_{i} space-separated integers. jj -th ( 1<=j<=ai1<=j<=a_{i} ) of these integers should be equal to the color of the jj -th pebble in the ii -th pile. If there are several possible answers, you may output any of them.

输入输出样例

  • 输入#1

    4 4
    1 2 3 4
    

    输出#1

    YES
    1
    1 4
    1 2 4
    1 2 3 4
    
  • 输入#2

    5 2
    3 2 4 1 3
    

    输出#2

    NO
    
  • 输入#3

    5 4
    3 2 4 3 5
    

    输出#3

    YES
    1 2 3
    1 3
    1 2 3 4
    1 3 4
    1 1 2 3 4
    
首页