結果

問題 No.318 学学学学学
ユーザー maine_honzukimaine_honzuki
提出日時 2021-05-31 10:24:16
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 621 bytes
コンパイル時間 2,063 ms
コンパイル使用メモリ 206,824 KB
実行使用メモリ 8,716 KB
最終ジャッジ日時 2023-08-08 15:23:26
合計ジャッジ時間 5,286 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,376 KB
testcase_01 AC 15 ms
4,376 KB
testcase_02 AC 18 ms
4,548 KB
testcase_03 AC 13 ms
4,380 KB
testcase_04 AC 16 ms
4,380 KB
testcase_05 AC 93 ms
8,716 KB
testcase_06 AC 101 ms
7,300 KB
testcase_07 AC 92 ms
6,540 KB
testcase_08 AC 82 ms
5,676 KB
testcase_09 AC 71 ms
5,192 KB
testcase_10 AC 59 ms
4,376 KB
testcase_11 AC 94 ms
8,616 KB
testcase_12 AC 73 ms
6,268 KB
testcase_13 AC 67 ms
5,352 KB
testcase_14 AC 61 ms
4,712 KB
testcase_15 AC 56 ms
4,444 KB
testcase_16 AC 49 ms
4,380 KB
testcase_17 AC 73 ms
8,616 KB
testcase_18 AC 54 ms
6,224 KB
testcase_19 AC 72 ms
8,600 KB
testcase_20 AC 34 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//https://ncode.syosetu.com/n4830bu/318/
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto&& a : A) {
        cin >> a;
    }
    vector<int> R(N, -1);
    set<int> seen;
    for (int i = N - 1; i >= 0; i--) {
        int a = A[i];
        if (!seen.count(a)) {
            seen.insert(a);
            R[i] = a;
        }
    }
    set<int> maine;
    for (int i = 0; i < N; i++) {
        int l = A[i], r = R[i];
        maine.insert(l);
        cout << *maine.rbegin() << " \n"[i == N - 1];
        if (r != -1)
            maine.erase(r);
    }
}
0