結果

問題 No.318 学学学学学
コンテスト
ユーザー otsnsk
提出日時 2016-10-24 15:33:16
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 740 ms / 2,000 ms
コード長 736 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 803 ms
コンパイル使用メモリ 96,120 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2026-03-06 23:29:23
合計ジャッジ時間 6,592 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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