結果

問題 No.318 学学学学学
ユーザー masamasa
提出日時 2015-12-11 17:21:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,062 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 2,040 ms
コンパイル使用メモリ 74,300 KB
実行使用メモリ 9,708 KB
最終ジャッジ日時 2023-09-04 17:30:56
合計ジャッジ時間 9,760 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,380 KB
testcase_01 AC 17 ms
4,504 KB
testcase_02 AC 22 ms
4,724 KB
testcase_03 AC 14 ms
4,376 KB
testcase_04 AC 18 ms
4,556 KB
testcase_05 AC 123 ms
9,704 KB
testcase_06 AC 762 ms
6,556 KB
testcase_07 AC 751 ms
5,436 KB
testcase_08 AC 607 ms
4,648 KB
testcase_09 AC 393 ms
4,376 KB
testcase_10 AC 95 ms
4,380 KB
testcase_11 AC 118 ms
9,708 KB
testcase_12 AC 81 ms
6,580 KB
testcase_13 AC 69 ms
5,424 KB
testcase_14 AC 63 ms
4,628 KB
testcase_15 AC 56 ms
4,376 KB
testcase_16 AC 49 ms
4,376 KB
testcase_17 AC 1,062 ms
6,616 KB
testcase_18 AC 62 ms
6,472 KB
testcase_19 AC 1,061 ms
6,476 KB
testcase_20 AC 34 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int main() {
	int n, a;

	cin >> n;
	vector<int> b(n, -1);

	map<int, pair<int, int> > num_range;

	for (int i = 0; i < n; i++) {
		cin >> a;
		auto it = num_range.find(a);

		if (it == num_range.end()) {
			num_range[a] = make_pair(i, i);
		} else {
			(*it).second.second = i;
		}
	}


	for (auto num : num_range) {
		if (num.second.second == -1) {
			continue;
		}

		for (int i = num.second.first; i <= num.second.second; i++) {
			b[i] = num.first;
		}
	}

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


	return 0;
}
0