結果

問題 No.489 株に挑戦
コンテスト
ユーザー %20
提出日時 2017-02-27 14:19:05
言語 C90
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 478 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 209 ms
コンパイル使用メモリ 39,704 KB
最終ジャッジ日時 2026-02-24 00:25:43
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class
    2 | b=1<<17;
      | ^
main.c:3:1: warning: data definition has no type or storage class
    3 | N,D,K,x[1<<19],j,k;
      | ^
main.c:4:1: warning: data definition has no type or storage class
    4 | l,r,L,R;
      | ^
main.c:5:1: warning: data definition has no type or storage class
    5 | i,t;
      | ^
main.c: In function 'main':
main.c:8:13: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    8 |         for(scanf("%d%d%d",&N,&D,&K);~scanf("%d",x+b+i++););
      |             ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | max(a,b){return a>b?a:b;}
main.c:22:17: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   22 |                 printf("%ld\n%d %d\n",m*K,j,k);
      |                 ^~~~~~
main.c:22:17: note: include '<stdio.h>' or provide a declaration of 'printf'

ソースコード

diff #
raw source code

max(a,b){return a>b?a:b;}
b=1<<17;
N,D,K,x[1<<19],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){
		for(L=x[l=b+i],R=x[r=b+i+D];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