結果
| 問題 | No.318 学学学学学 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-22 05:55:35 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 444 ms / 2,000 ms |
| コード長 | 698 bytes |
| 記録 | |
| コンパイル時間 | 1,451 ms |
| コンパイル使用メモリ | 217,868 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2026-06-28 06:56:15 |
| 合計ジャッジ時間 | 5,327 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int n; cin >> n;
vector<int> a(n);
rep(i,n) cin >> a[i];
vector<int> ans(n);
multiset<int> L, R(a.begin(), a.end()), st;
rep(i,n) {
R.erase(R.lower_bound(a[i]));
if(L.count(a[i]) && !R.count(a[i])) st.erase(st.lower_bound(a[i]));
ans[i] = a[i];
if(!st.empty()) ans[i] = max(ans[i], *st.rbegin());
if(!L.count(a[i]) && R.count(a[i])) st.insert(a[i]);
L.insert(a[i]);
}
rep(i,n) cout << ans[i] << " \n"[i == n - 1];
}