結果

問題 No.318 学学学学学
ユーザー otsnsk
提出日時 2016-10-24 15:33:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1,091 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 895 ms
コンパイル使用メモリ 71,960 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-22 18:05:58
合計ジャッジ時間 7,795 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

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