結果

問題 No.318 学学学学学
ユーザー cielciel
提出日時 2015-12-11 10:54:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 531 bytes
コンパイル時間 1,245 ms
コンパイル使用メモリ 68,580 KB
実行使用メモリ 18,816 KB
最終ジャッジ日時 2023-09-04 17:22:21
合計ジャッジ時間 4,710 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
4,420 KB
testcase_01 AC 27 ms
5,796 KB
testcase_02 AC 34 ms
6,412 KB
testcase_03 AC 21 ms
5,324 KB
testcase_04 AC 29 ms
5,948 KB
testcase_05 AC 230 ms
18,808 KB
testcase_06 AC 166 ms
12,016 KB
testcase_07 AC 126 ms
9,624 KB
testcase_08 AC 89 ms
7,244 KB
testcase_09 AC 65 ms
5,124 KB
testcase_10 AC 42 ms
4,376 KB
testcase_11 AC 227 ms
18,816 KB
testcase_12 AC 126 ms
10,988 KB
testcase_13 AC 92 ms
8,288 KB
testcase_14 AC 66 ms
6,208 KB
testcase_15 AC 46 ms
4,648 KB
testcase_16 AC 30 ms
4,380 KB
testcase_17 AC 121 ms
13,320 KB
testcase_18 AC 87 ms
10,860 KB
testcase_19 AC 108 ms
13,300 KB
testcase_20 AC 26 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 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 <vector>
#include <map>
#include <set>
#include <cstdio>
using namespace std;
int main(){
	int N;
	scanf("%d",&N);
	map<int,pair<int,int> >m;
	vector<int>v(N);
	for(int i=0,x;i<N;i++){
		scanf("%d",&x);
		v[i]=x;
		if(m.find(x)==m.end())m[x]=make_pair(i,i);
		else m[x].second=i;
	}
	set<int>sa,sb,s;
	for(auto &e:m)sa.insert(e.second.first),sb.insert(e.second.second);
	for(int i=0;i<N;i++){
		if(sa.find(i)!=sa.end())s.insert(v[i]);
		printf(i<N-1?"%d ":"%d\n",*s.rbegin());
		if(sb.find(i)!=sb.end())s.erase(v[i]);
	}
}
0