Corrupted Contest
题号:NC222619
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

You are organizing a programming competition in which the rank of a team is fifirst determined by how many problems they have solved. In case of a tie, the team with the lowest time penalty is ranked above the other. However, contrary to the BAPC, the time penalty is equal to t if the latest accepted submission was submitted in the tth minute, or 0 if no problem was solved.
For example, if team A solved their fifirst problem in the 5th minute, their second problem in the 10th minute and their third problem in the 60th minute, then their time penalty is 60. If team B also solved three problems, in the 30th, 40th and 50th minute, their time penalty is 50 and they would rank above team A.
 The contest has fifinished and you would like to enter the fifinal standings. However, due to a corrupted fifile you have lost part of the scoreboard. In particular, the column indicating how many problems each team has solved is gone. You do still have the time penalties of all the teams and know that they are in the right order. You also remember how many problems the contest had. You wonder whether, given this information, it is possible to uniquely reconstruct the number of problems that each team has solved.

输入描述:

The input consists of:
     •One line containing two integers: n (1 ≤ n ≤ 104), the number of teams participating,and p (1 ≤ p ≤ 104), the number of contest problems.
     •n lines with on line i the time score tiin minutes (0 ≤ ti ≤ 106) of the team that is ranked in the ith place.
A positive time score of t indicates that a team has submitted their last accepted submission in the tth minute. A time score of 0 indicates that a team hasn’t solved any problem.
The input always originates from a valid scoreboard.

输出描述:

If it is possible to uniquely reconstruct the scores of all the teams, output n lines containing the number of problems that the ith team has solved on the ith line. Otherwise, output “ambiguous”.
示例1

输入

复制
9 3
140
75
101
120
30
70
200
0
0

输出

复制
3
2
2
2
1
1
1
0
0
示例2

输入

复制
6 3
100
40
40
50
0
0

输出

复制
ambiguous