結果

問題 No.871 かえるのうた
ユーザー tailstails
提出日時 2019-08-30 22:24:10
言語 Perl
(5.38.0)
結果
AC  
実行時間 733 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 1,039 ms
コンパイル使用メモリ 6,984 KB
実行使用メモリ 40,852 KB
最終ジャッジ日時 2023-08-20 09:20:39
合計ジャッジ時間 12,932 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,304 KB
testcase_01 AC 6 ms
5,124 KB
testcase_02 AC 7 ms
5,136 KB
testcase_03 AC 7 ms
5,136 KB
testcase_04 AC 7 ms
5,136 KB
testcase_05 AC 6 ms
5,240 KB
testcase_06 AC 7 ms
5,168 KB
testcase_07 AC 7 ms
5,220 KB
testcase_08 AC 20 ms
6,332 KB
testcase_09 AC 23 ms
6,464 KB
testcase_10 AC 10 ms
5,408 KB
testcase_11 AC 14 ms
5,764 KB
testcase_12 AC 110 ms
12,236 KB
testcase_13 AC 29 ms
6,804 KB
testcase_14 AC 553 ms
38,884 KB
testcase_15 AC 576 ms
38,872 KB
testcase_16 AC 682 ms
40,852 KB
testcase_17 AC 621 ms
36,832 KB
testcase_18 AC 110 ms
12,336 KB
testcase_19 AC 683 ms
38,884 KB
testcase_20 AC 65 ms
8,000 KB
testcase_21 AC 260 ms
17,456 KB
testcase_22 AC 7 ms
5,304 KB
testcase_23 AC 7 ms
5,368 KB
testcase_24 AC 7 ms
5,116 KB
testcase_25 AC 19 ms
5,964 KB
testcase_26 AC 62 ms
8,792 KB
testcase_27 AC 83 ms
10,776 KB
testcase_28 AC 7 ms
5,196 KB
testcase_29 AC 321 ms
27,684 KB
testcase_30 AC 568 ms
29,836 KB
testcase_31 AC 25 ms
6,052 KB
testcase_32 AC 469 ms
27,024 KB
testcase_33 AC 666 ms
38,040 KB
testcase_34 AC 186 ms
14,628 KB
testcase_35 AC 423 ms
25,424 KB
testcase_36 AC 562 ms
32,656 KB
testcase_37 AC 323 ms
19,608 KB
testcase_38 AC 733 ms
37,576 KB
testcase_39 AC 673 ms
35,712 KB
testcase_40 AC 345 ms
28,692 KB
testcase_41 AC 7 ms
5,292 KB
testcase_42 AC 293 ms
28,680 KB
testcase_43 AC 7 ms
5,108 KB
testcase_44 AC 7 ms
5,316 KB
testcase_45 AC 14 ms
5,792 KB
testcase_46 AC 6 ms
5,164 KB
testcase_47 AC 6 ms
5,160 KB
testcase_48 AC 6 ms
5,320 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

use integer;
($n,$k)=glob<>;
@x=glob<>;
@a=glob<>;
--$k;
$l=$x[$k]-$a[$k];
$r=$x[$k]+$a[$k];
$i=$k-1;
$j=$k+1;
while(1){
	if($i>=0 && $x[$i]>=$l){
		$l=$x[$i]-$a[$i] if $l>$x[$i]-$a[$i];
		$r=$x[$i]+$a[$i] if $r<$x[$i]+$a[$i];
		--$i;
	}
	elsif($j<$n && $x[$j]<=$r){
		$l=$x[$j]-$a[$j] if $l>$x[$j]-$a[$j];
		$r=$x[$j]+$a[$j] if $r<$x[$j]+$a[$j];
		++$j;
	}
	else{
		last;
	}
}
print $j-$i-1;
0