結果

問題 No.489 株に挑戦
ユーザー %20%20
提出日時 2017-02-27 14:27:27
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 22 ms / 1,000 ms
コード長 520 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 23:35:54
合計ジャッジ時間 1,649 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
5,248 KB
testcase_01 AC 11 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 17 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 10 ms
5,376 KB
testcase_19 AC 8 ms
5,376 KB
testcase_20 AC 18 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 9 ms
5,376 KB
testcase_24 AC 21 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 20 ms
5,376 KB
testcase_27 AC 20 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 22 ms
5,376 KB
testcase_31 AC 20 ms
5,376 KB
testcase_32 AC 11 ms
5,376 KB
testcase_33 AC 20 ms
5,376 KB
testcase_34 AC 18 ms
5,376 KB
testcase_35 AC 8 ms
5,376 KB
testcase_36 AC 4 ms
5,376 KB
testcase_37 AC 11 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    1 | max(a,b){return a>b?a:b;}
      | ^~~
main.c: In function ‘max’:
main.c:1:1: warning: type of ‘a’ defaults to ‘int’ [-Wimplicit-int]
main.c:1:1: warning: type of ‘b’ defaults to ‘int’ [-Wimplicit-int]
main.c: At top level:
main.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    2 | min(a,b){return a<b?a:b;}
      | ^~~
main.c: In function ‘min’:
main.c:2:1: warning: type of ‘a’ defaults to ‘int’ [-Wimplicit-int]
main.c:2:1: warning: type of ‘b’ defaults to ‘int’ [-Wimplicit-int]
main.c: At top level:
main.c:3:1: warning: data definition has no type or storage class
    3 | b=1<<17;
      | ^
main.c:3:1: warning: type defaults to ‘int’ in declaration of ‘b’ [-Wimplicit-int]
main.c:4:1: warning: data definition has no type or storage class
    4 | N,D,K,x[1<<18],j,k;
      | ^
main.c:4:1: warning: type defaults to ‘int’ in declaration of ‘N’ [-Wimplicit-int]
main.c:4:3: warning: type defaults to ‘int’ in declaration of ‘D’ [-Wimplicit-int]
    4 | N,D,K,x[1<<18],j,k;
      |   ^
main.c:4:5: warning: type defaults to ‘int’ in declaration of ‘K’ [-Wimplicit-int]
    4 | N,D,K,x[1<<18],j,k;
      |     ^
main.c:4:7: warning: type defaults to ‘int’ in declaration of ‘x’ [-Wimplicit-int]
    4 | N,D,K,x[1<<18],j,k;
      |       ^
main.c:4:16: warning: type defaults to ‘int’ in declaration of ‘j’ [-Wimplicit-int]
    4 | N,D,K,x[1<<18],j,k;
      |                ^
main.c:4:18: warning: type defaults to ‘int’ in declaration of ‘k’ [-Wimplicit-int]
    4 | N,D,K,x[1<<18],j,k;
      |                  ^
main.c:5:1: warning: data definition has no type or storage class
    5 | l,r,L,R;
      | ^
main.c:5:1: warning: type defaults to ‘int’ in declaration of ‘l’ [-Wimplicit-int]
main.c:5:3: warning: type defaults to ‘int’ in declaration of ‘r’ [-Wimplicit-int]
    5 | l

ソースコード

diff #

max(a,b){return a>b?a:b;}
min(a,b){return a<b?a:b;}
b=1<<17;
N,D,K,x[1<<18],j,k;
l,r,L,R;
i,t;
long m;
main(){
	for(scanf("%d%d%d",&N,&D,&K);~scanf("%d",x+b+i++););
	for(i=b;--i;)x[i]=max(x[i*2],x[i*2+1]);
	for(i=0;i<N;++i){
		L=x[l=b+i];
		R=x[r=b+min(i+D,N-1)];
		for(;l>>1!=r>>1;l>>=1,r>>=1){
			l&1||(L=max(L,x[l^1]));
			r&1&&(R=max(R,x[r^1]));
		}
		if((t=max(L,R)-x[b+i]-m)>0){
			j=i;
			m+=t;
		}
	}
	if(m){
		for(k=j;x[b+k]-x[b+j]!=m;++k);
		printf("%ld\n%d %d\n",m*K,j,k);
	}else{
		puts("0");
	}
	return 0;
}
0