結果

問題 No.489 株に挑戦
ユーザー tailstails
提出日時 2017-02-24 23:56:42
言語 C90
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 661 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-10 23:35:27
合計ジャッジ時間 2,167 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,248 KB
testcase_01 AC 10 ms
5,376 KB
testcase_02 AC 1 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 1 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 1 ms
5,376 KB
testcase_16 RE -
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 9 ms
5,376 KB
testcase_19 AC 8 ms
5,376 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 7 ms
5,376 KB
testcase_24 AC 19 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 18 ms
5,376 KB
testcase_27 AC 17 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 RE -
testcase_31 AC 18 ms
5,376 KB
testcase_32 AC 10 ms
5,376 KB
testcase_33 AC 18 ms
5,376 KB
testcase_34 AC 17 ms
5,376 KB
testcase_35 AC 7 ms
5,376 KB
testcase_36 AC 4 ms
5,376 KB
testcase_37 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | X[0x40000];
      | ^
main.c:1:1: warning: type defaults to ‘int’ in declaration of ‘X’ [-Wimplicit-int]
main.c:3:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    3 | f(i,j){
      | ^
main.c: In function ‘f’:
main.c:3:1: warning: type of ‘i’ defaults to ‘int’ [-Wimplicit-int]
main.c:3:1: warning: type of ‘j’ defaults to ‘int’ [-Wimplicit-int]
main.c: At top level:
main.c:21:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
   21 | main(){
      | ^~~~
main.c: In function ‘main’:
main.c:24:9: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
   24 |         scanf("%d%d%d",&n,&d,&k);
      |         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | X[0x40000];
main.c:24:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
   24 |         scanf("%d%d%d",&n,&d,&k);
      |         ^~~~~
main.c:24:9: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:48:17: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   48 |                 printf("%lld\n%d %d\n",1ll*b*k,j0,j1);
      |                 ^~~~~~
main.c:48:17: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:48:17: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
main.c:48:17: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:50:17: warning: implicit declaration of function ‘puts’ [-Wimplicit-function-declaration]
   50 |                 puts("0");
      |                 ^~~~
main.c:50:17: note: include ‘<stdio.h>’ or provide a declaration of ‘puts’

ソースコード

diff #

X[0x40000];

f(i,j){
	int b=1e9;
	while(i<=j){
		if(i&1){
			if(b>X[i])b=X[i];
			++i;
		}
		if(!(j&1)){
			if(b>X[j])b=X[j];
			--j;
		}
		i=0x20000|i>>1;
		j=0x20000|j>>1;
	}
	return b;
}


main(){
	int i,j,n,d,k,b;
	int j0,j1;
	scanf("%d%d%d",&n,&d,&k);
	for(i=0;i<n;++i){
		scanf("%d",&X[i]);
	}

	for(i=0;i<0x20000;++i){
		int x0=X[i<<1|0];
		int x1=X[i<<1|1];
		X[i|0x20000]=x0<x1?x0:x1;
	}

	b=0;
	for(i=0;i<n;++i){
		int z=f(j=i-d<0?0:i-d,i);
		int c=X[i]-f(j=i-d<0?0:i-d,i);
		if(b<c) b=c,j1=i;
	}
	if(b){
		for(i=j1-d;i<j1;++i){
			if (b==X[j1]-X[i]){
				j0=i;
				break;
			}
		}
		printf("%lld\n%d %d\n",1ll*b*k,j0,j1);
	}else{
		puts("0");
	}
}
	
0