結果

問題 No.318 学学学学学
ユーザー fiordfiord
提出日時 2015-12-17 06:24:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 159,384 KB
実行使用メモリ 10,224 KB
最終ジャッジ日時 2023-09-04 18:13:10
合計ジャッジ時間 5,296 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,380 KB
testcase_01 AC 23 ms
4,380 KB
testcase_02 AC 28 ms
4,576 KB
testcase_03 AC 19 ms
4,380 KB
testcase_04 AC 25 ms
4,464 KB
testcase_05 AC 182 ms
10,224 KB
testcase_06 AC 156 ms
8,492 KB
testcase_07 AC 131 ms
7,252 KB
testcase_08 AC 114 ms
5,788 KB
testcase_09 AC 98 ms
5,172 KB
testcase_10 AC 75 ms
4,504 KB
testcase_11 AC 179 ms
10,104 KB
testcase_12 AC 113 ms
6,692 KB
testcase_13 AC 94 ms
5,560 KB
testcase_14 AC 82 ms
5,016 KB
testcase_15 AC 69 ms
4,816 KB
testcase_16 AC 53 ms
4,376 KB
testcase_17 AC 93 ms
8,480 KB
testcase_18 AC 81 ms
7,596 KB
testcase_19 AC 84 ms
8,752 KB
testcase_20 AC 39 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,384 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;	cin>>n;
	vector<int> a(n);
	map<int,int> ls;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ls[a[i]]++;
	}
	set<int> used;
	vector<int> b;
	for(int i=0;i<n;i++){
		used.insert(a[i]);
		auto it=used.rbegin();
		while(it!=used.rend()&&ls[*it]==0){
			used.erase(*it);	it=used.rbegin();
		}
		b.push_back(*it);
		ls[a[i]]--;
	}
	for(int i=0;i<(int)b.size();i++)	cout<<(i?" ":"")<<b[i];	
	cout<<endl;
	return 0;
}
	
0