結果

問題 No.318 学学学学学
ユーザー rogi52rogi52
提出日時 2022-10-22 05:55:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 415 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 1,818 ms
コンパイル使用メモリ 206,376 KB
実行使用メモリ 11,024 KB
最終ジャッジ日時 2023-09-14 03:31:34
合計ジャッジ時間 6,247 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,380 KB
testcase_01 AC 17 ms
4,568 KB
testcase_02 AC 19 ms
4,528 KB
testcase_03 AC 13 ms
4,376 KB
testcase_04 AC 18 ms
4,380 KB
testcase_05 AC 123 ms
8,588 KB
testcase_06 AC 156 ms
9,648 KB
testcase_07 AC 152 ms
9,596 KB
testcase_08 AC 149 ms
9,324 KB
testcase_09 AC 157 ms
9,076 KB
testcase_10 AC 415 ms
8,552 KB
testcase_11 AC 121 ms
8,544 KB
testcase_12 AC 112 ms
8,568 KB
testcase_13 AC 106 ms
8,544 KB
testcase_14 AC 99 ms
8,620 KB
testcase_15 AC 97 ms
8,544 KB
testcase_16 AC 131 ms
8,548 KB
testcase_17 AC 84 ms
10,916 KB
testcase_18 AC 63 ms
8,556 KB
testcase_19 AC 88 ms
11,024 KB
testcase_20 AC 183 ms
8,584 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];
}
0