結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,468 KB
testcase_01 AC 25 ms
5,796 KB
testcase_02 AC 31 ms
6,424 KB
testcase_03 AC 21 ms
5,260 KB
testcase_04 AC 28 ms
6,008 KB
testcase_05 AC 222 ms
18,816 KB
testcase_06 AC 160 ms
12,072 KB
testcase_07 AC 124 ms
9,556 KB
testcase_08 AC 91 ms
7,264 KB
testcase_09 AC 69 ms
5,140 KB
testcase_10 AC 42 ms
4,380 KB
testcase_11 AC 213 ms
18,736 KB
testcase_12 AC 126 ms
10,960 KB
testcase_13 AC 93 ms
8,300 KB
testcase_14 AC 64 ms
6,208 KB
testcase_15 AC 45 ms
4,588 KB
testcase_16 AC 29 ms
4,376 KB
testcase_17 AC 113 ms
13,280 KB
testcase_18 AC 85 ms
10,984 KB
testcase_19 AC 107 ms
13,272 KB
testcase_20 AC 25 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <map>
#include <set>
#include <cstdio>
using namespace std;
int main(){
	int N,x,i=0;scanf("%d",&N);
	map<int,pair<int,int>>m;
	vector<int>v(N);
	set<int>sa,sb,s;
	for(;i<N;i++){
		scanf("%d",&x);
		v[i]=x;
		if(m.find(x)==m.end())sa.insert(i),m[x]={i,i};
		else m[x].second=i;
	}
	for(auto &e:m)sb.insert(e.second.second);
	for(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