AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

BAPC20-051.\problemyamlname

Medium · 1 s · 256 MB

  • icpc
  • bapc
  • 2020

You are organizing a programming competition in which the rank of a team is first 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 ttt if the latest accepted submission was submitted in the tttth minute, or 000 if no problem was solved.

For example, if team A solved their first problem in the 555th minute, their second problem in the 101010th minute and their third problem in the 606060th minute, then their time penalty is 606060. If team B also solved three problems, in the 303030th, 404040th and 505050th minute, their time penalty is 505050 and they would rank above team A.

The contest has finished and you would like to enter the final standings. However, due to a corrupted file 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.

Giriş formatı

The input consists of:

• One line containing two integers: nnn (1≤n≤1041 \le n \le 10^41≤n≤104), the number of teams participating, and ppp (1≤p≤1041 \le p \le 10^41≤p≤104), the number of contest problems.

• nnn lines with on line iii the time score tit_iti​ in minutes (0≤ti≤1060 \le t_i \le 10^60≤ti​≤106) of the team that is ranked in the iiith place.

A positive time score of ttt indicates that a team has submitted their last accepted submission in the tttth minute. A time score of 000 indicates that a team hasn't solved any problem.

The input always originates from a valid scoreboard.

Çıxış formatı

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

Qeyd

Source: Benelux Algorithm Programming Contest 2020 · Author: Boas Kluiving · License: CC BY-SA 4.0 · Original: https://bapc.eu · Statement adapted for AlgoLens and shared under the same license.

Nümunələr

Giriş #1

9 3
140
75
101
120
30
70
200
0
0

Çıxış #1

3
2
2
2
1
1
1
0
0

Giriş #2

6 3
100
40
40
50
0
0

Çıxış #2

ambiguous