結果

問題 No.318 学学学学学
ユーザー piyoko_212piyoko_212
提出日時 2015-12-21 19:40:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 674 bytes
コンパイル時間 1,141 ms
コンパイル使用メモリ 45,948 KB
実行使用メモリ 5,088 KB
最終ジャッジ日時 2023-10-18 22:03:26
合計ジャッジ時間 4,868 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,348 KB
testcase_01 AC 12 ms
4,348 KB
testcase_02 AC 14 ms
4,348 KB
testcase_03 AC 10 ms
4,348 KB
testcase_04 AC 12 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 37 ms
4,880 KB
testcase_17 AC 50 ms
5,088 KB
testcase_18 AC 44 ms
4,880 KB
testcase_19 AC 49 ms
4,880 KB
testcase_20 WA -
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         int a;scanf("%d",&a);
      |               ~~~~~^~~~~~~~~
main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |                 scanf("%d",b+i);
      |                 ~~~~~^~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<algorithm>
#include<stack>
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;
	}
	stack<int>S;
	for(int i=0;i<a;i++){
		if(i)printf(" ");
		int t=lower_bound(z,z+a,b[i])-z;
		if(S.size()==0||z[S.top()]<b[i]){
			S.push(t);
		}
		printf("%d",z[S.top()]);
		while(S.size()&&r[S.top()]<=i){
			S.pop();
		}
	}
	printf("\n");
}
0