結果

問題 No.318 学学学学学
ユーザー otsnskotsnsk
提出日時 2016-10-24 15:33:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,128 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 71,728 KB
実行使用メモリ 10,952 KB
最終ジャッジ日時 2023-09-04 20:33:47
合計ジャッジ時間 9,289 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,376 KB
testcase_01 AC 17 ms
4,432 KB
testcase_02 AC 21 ms
4,680 KB
testcase_03 AC 14 ms
4,472 KB
testcase_04 AC 18 ms
4,460 KB
testcase_05 AC 113 ms
10,952 KB
testcase_06 AC 804 ms
7,856 KB
testcase_07 AC 795 ms
6,720 KB
testcase_08 AC 643 ms
5,908 KB
testcase_09 AC 417 ms
5,212 KB
testcase_10 AC 99 ms
4,552 KB
testcase_11 AC 108 ms
10,884 KB
testcase_12 AC 80 ms
7,804 KB
testcase_13 AC 71 ms
6,696 KB
testcase_14 AC 67 ms
5,864 KB
testcase_15 AC 60 ms
5,216 KB
testcase_16 AC 52 ms
4,600 KB
testcase_17 AC 1,127 ms
7,796 KB
testcase_18 AC 59 ms
7,860 KB
testcase_19 AC 1,128 ms
7,852 KB
testcase_20 AC 37 ms
4,720 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>

typedef long long ll;

using namespace std;

int main() {
    int n, i;
    cin >> n;
    vector<ll> a(n), b(n);
    map<ll, pair<int, int>> rng;

    for (i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for (i = 0; i < n; ++i) {
        auto it = rng.find(a[i]);
        if (it == rng.end()) {
            rng[a[i]] = make_pair(i, i);
        }
        else {
            it->second.second = i;
        }
    }
    for (auto p: rng) {
        auto lr = p.second;
        for (i = lr.first; i <= lr.second; ++i) {
            b[i] = p.first;
        }
    }

    cout << b[0];
    for (i = 1; i < n; ++i) {
        cout << ' ' << b[i];
    }
    cout << endl;

    return 0;
}
0