結果

問題 No.489 株に挑戦
ユーザー tailstails
提出日時 2017-02-24 23:37:55
言語 Perl
(5.38.2)
結果
TLE  
実行時間 -
コード長 616 bytes
コンパイル時間 53 ms
コンパイル使用メモリ 5,300 KB
実行使用メモリ 34,876 KB
最終ジャッジ日時 2023-08-31 00:11:41
合計ジャッジ時間 7,328 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 60 ms
14,564 KB
testcase_03 AC 61 ms
14,528 KB
testcase_04 AC 61 ms
14,568 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 62 ms
14,548 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 TLE -
testcase_17 AC 110 ms
17,008 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Name "main::z" used only once: possible typo at Main.pl line 36.
Main.pl syntax OK

ソースコード

diff #

($n,$d,$k)=glob<>;
@x=<>;

for$i(0..0x1ffff){
	$x0=$x[$i<<1|0];
	$x1=$x[$i<<1|1];
	$x[$i|0x20000]=$x0<$x1?$x0:$x1;
}

sub f{
	my($i,$j)=@_;
#print("f($i,$j)");
	my$b=1e9;
	if($i&1){
		$b=$x[$i++];
	}
	if(!($j&1)){
		$b=$x[$j] if $b>$x[$j];
		--$j;
	}
	if($i<$j){
		$i=0x20000|$i>>1;
		$j=0x20000|$j>>1;
		$b1=f($i,$j);
		$b=$b1 if $b>$b1;
	}
	$b;
}

#print">>",f(0,1),$/;
#print">>",f(1,2),$/;
#exit(1);

$b=0;
for$i(0..$n-1){
	$z=f($j=$i-$d<0?0:$i-$d,$i);
#print"$i:$z\n";
	$c=$x[$i]- f($j=$i-$d<0?0:$i-$d,$i);
	$b=$c,$j0=$j,$j1=$i if $b<$c;
#print"$b\n";
}
if($b){
	print $b*$k,$/,$j0,$",$j1;
}else{
	print 0;
}
	
0