#B. C - Exception Handling

    传统题 1000ms 256MiB

C - Exception Handling

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

C - Exception Handling

Score : $300$ points

Problem Statement

You are given a sequence of length $N$: $A_1, A_2, ..., A_N$. For each integer $i$ between $1$ and $N$ (inclusive), answer the following question:

  • Find the maximum value among the $N-1$ elements other than $A_i$ in the sequence.

Constraints

  • $2 \leq N \leq 200000$
  • $1 \leq A_i \leq 200000$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1

::

ANA_N

Output

Print $N$ lines. The $i$-th line ($1 \leq i \leq N$) should contain the maximum value among the $N-1$ elements other than $A_i$ in the sequence.


3
1
4
3
4
3
4
  • The maximum value among the two elements other than $A_1$, that is, $A_2 = 4$ and $A_3 = 3$, is $4$.
  • The maximum value among the two elements other than $A_2$, that is, $A_1 = 1$ and $A_3 = 3$, is $3$.
  • The maximum value among the two elements other than $A_3$, that is, $A_1 = 1$ and $A_2 = 4$, is $4$.

2
5
5
5
5

2024暑假入门组刷题营第三期(六)

未参加
状态
已结束
规则
IOI
题目
8
开始于
2024-7-13 13:00
结束于
2024-7-13 15:00
持续时间
2 小时
主持人
参赛人数
8