結果

問題 No.318 学学学学学
ユーザー piyoko_212piyoko_212
提出日時 2015-12-21 19:45:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 55,376 KB
実行使用メモリ 6,964 KB
最終ジャッジ日時 2023-09-04 18:28:10
合計ジャッジ時間 4,176 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,380 KB
testcase_01 AC 12 ms
4,380 KB
testcase_02 AC 14 ms
4,384 KB
testcase_03 AC 10 ms
4,380 KB
testcase_04 AC 13 ms
4,384 KB
testcase_05 AC 75 ms
4,644 KB
testcase_06 AC 101 ms
5,784 KB
testcase_07 AC 91 ms
5,844 KB
testcase_08 AC 82 ms
5,468 KB
testcase_09 AC 75 ms
5,052 KB
testcase_10 AC 62 ms
4,696 KB
testcase_11 AC 76 ms
4,656 KB
testcase_12 AC 72 ms
4,624 KB
testcase_13 AC 68 ms
4,652 KB
testcase_14 AC 60 ms
4,624 KB
testcase_15 AC 51 ms
4,664 KB
testcase_16 AC 34 ms
4,576 KB
testcase_17 AC 62 ms
6,964 KB
testcase_18 AC 48 ms
4,612 KB
testcase_19 AC 63 ms
6,924 KB
testcase_20 AC 36 ms
4,624 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,384 KB
testcase_24 AC 2 ms
4,384 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<algorithm>
#include<stack>
#include<set>
using namespace std;
int b[110000];
int z[110000];
int l[110000];
int r[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
		z[i]=b[i];
		l[i]=r[i]=-1;
	}
	std::sort(z,z+a);
	for(int i=0;i<a;i++){
		int t=lower_bound(z,z+a,b[i])-z;
		if(l[t]==-1)l[t]=i;
	}
	for(int i=a-1;i>=0;i--){
		int t=lower_bound(z,z+a,b[i])-z;
		if(r[t]==-1)r[t]=i;
	}
	set<int>S;
	for(int i=0;i<a;i++){
		if(i)printf(" ");
		int t=lower_bound(z,z+a,b[i])-z;
		if(i==l[t]){
			S.insert(z[t]);
		}
		printf("%d",*(S.rbegin()));
		if(i==r[t])S.erase(z[t]);
	}
	printf("\n");
}
0