碎碎念
C - Exception Handling

Input is given from Standard Input in the following format:
N
A1
:
AN
Print N lines. The i-th line (1≤i≤N) should contain the maximum value among the N−1 elements other than A_i in the sequence.
3
1
4
34
3
4
2
5
5
5
5
void coder_solution() {
// 提升cin、cout效率
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<int> a(n);
vector<int> dp(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
dp[i] = a[i];
}
sort(dp.begin(), dp.end());
for (int i = 0; i < n; ++i) {
if(a[i] == dp[n - 1]) {
cout << dp[n - 2] << endl;
} else {
cout << dp[n - 1] << endl;
}
}
}
int N, A[201010];
int lft[201010], rht[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N;
rep(i, 0, N) cin >> A[i];
rep(i, 0, N) lft[i] = A[i];
rep(i, 1, N) chmax(lft[i], lft[i - 1]);
rep(i, 0, N) rht[i] = A[i];
rrep(i, N - 2, 0) chmax(rht[i], rht[i + 1]);
rep(i, 0, N) {
int ans = -1;
if (0 < i) chmax(ans, lft[i - 1]);
if (i + 1 < N) chmax(ans, rht[i + 1]);
printf("%d\n", ans);
}
}