結果
問題 | No.318 学学学学学 |
ユーザー |
|
提出日時 | 2022-10-22 05:46:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 780 bytes |
コンパイル時間 | 1,735 ms |
コンパイル使用メモリ | 200,924 KB |
最終ジャッジ日時 | 2025-02-08 11:00:12 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 11 |
ソースコード
#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]; multiset<int> L, R(a.begin(), a.end()); vector<int> ans(n); rep(i,n) { R.erase(R.lower_bound(a[i])); int x = a[i]; if(!L.empty()) { auto itL = L.end(); itL--; if(R.count(*itL)) x = max(x, *itL); } if(!R.empty()) { auto itR = R.end(); itR--; if(L.count(*itR)) x = max(x, *itR); } ans[i] = (x == -1 ? a[i] : x); L.insert(a[i]); } rep(i,n) cout << ans[i] << " \n"[i == n - 1]; }