oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

exceptionhandling Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

exceptionhandling.html

exceptionhandling

Problem Statement

You are given a sequence of length N: A1, A2, ..., AN. For each integer i between 1 and N (inclusive), answer the following question:

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

Constraints

  • 2 ≤ N ≤ 200000
  • 1 ≤ Ai ≤ 200000
  • All values in input are integers.

Partial Scores

  • In the test set worth 35 points, N ≦ 2000.

Input

Input is given from Standard Input in the following format:

N
A1
:
AN

Output

Print N lines. The i-th line (1 ≤ i ≤ N) should contain the maximum value among the N-1 elements other than Ai in the sequence.

Sample Input 1

3
1
4
3

Sample Output 1

4
3
4
  • The maximum value among the two elements other than A1, that is, A2 = 4 and A3 = 3, is 4.
  • The maximum value among the two elements other than A2, that is, A1 = 1 and A3 = 3, is 3.
  • The maximum value among the two elements other than A3, that is, A1 = 1 and A2 = 4, is 4.

Sample Input 2

2
5
5

Sample Output 2

5
5

Tags

Syntax, Data Structure

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
135121s256MBMinimum
265341s256MBMinimum
3021s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o exceptionhandling -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.