#P14505. [NCPC 2025] km/h

[NCPC 2025] km/h

Description

Many countries have a "national speed limit": a default maximum speed that applies unless a speed limit sign\emph{speed limit sign} explicitly sets a lower one. Such a speed limit sign shows a number and overrides the default while it is in force. By contrast, a derestriction sign\emph{derestriction sign} shows no number at all; it cancels the previous restriction and restores the national speed limit, which is always strictly higher than any speed limit sign.

You pride yourself on being a careful and attentive motorist. Whenever you encounter a speed limit sign, you smoothly and safely adjust your vehicle's speed. Alas, despite your otherwise impeccable memory, the derestriction sign always leaves you guessing. You simply cannot remember the national speed limit -- only that it was a neat multiple of ten.

As you encounter each sign -- limit or derestriction -- determine the fastest you can go while abiding the law, based only on what you've seen so far.

Input Format

The input consists of:

  • One line with an integer NN with 1N1001\leq N\leq 100, the number of signs.
  • NN lines, one for each sign. Each line describes either a speed limit or a derestriction. A speed limit is an integer LL with 10L16010\leq L\leq 160, the speed limit that applies from that sign. A derestriction is the forward slash /\texttt{/}, reminiscent of the sign's diagonal bar. The first line contains a speed limit. There are never two consecutive derestrictions.

Output Format

Output NN integers, the maximum legal speed that can be inferred when passing the iith sign for 1iN1\leq i\leq N.

8
90
85
/
119
/
85
85
/
90
85
100
119
120
85
85
120