結果

問題 No.281 門松と魔法(1)
ユーザー tailstails
提出日時 2015-09-19 00:01:49
言語 Perl
(5.38.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 565 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 4,724 KB
最終ジャッジ日時 2023-08-06 16:29:59
合計ジャッジ時間 2,052 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,500 KB
testcase_01 AC 2 ms
4,564 KB
testcase_02 AC 2 ms
4,568 KB
testcase_03 AC 3 ms
4,572 KB
testcase_04 AC 3 ms
4,584 KB
testcase_05 AC 3 ms
4,572 KB
testcase_06 AC 3 ms
4,572 KB
testcase_07 AC 3 ms
4,644 KB
testcase_08 AC 2 ms
4,564 KB
testcase_09 AC 3 ms
4,492 KB
testcase_10 AC 3 ms
4,504 KB
testcase_11 AC 3 ms
4,572 KB
testcase_12 AC 3 ms
4,724 KB
testcase_13 AC 2 ms
4,576 KB
testcase_14 AC 3 ms
4,580 KB
testcase_15 AC 3 ms
4,572 KB
testcase_16 AC 2 ms
4,584 KB
testcase_17 AC 2 ms
4,572 KB
testcase_18 AC 3 ms
4,580 KB
testcase_19 AC 3 ms
4,560 KB
testcase_20 AC 3 ms
4,652 KB
testcase_21 AC 3 ms
4,500 KB
testcase_22 AC 3 ms
4,572 KB
testcase_23 AC 2 ms
4,512 KB
testcase_24 AC 3 ms
4,572 KB
testcase_25 AC 3 ms
4,584 KB
testcase_26 AC 3 ms
4,560 KB
testcase_27 AC 3 ms
4,588 KB
testcase_28 AC 2 ms
4,512 KB
testcase_29 AC 3 ms
4,564 KB
testcase_30 AC 3 ms
4,504 KB
testcase_31 AC 3 ms
4,476 KB
testcase_32 AC 2 ms
4,480 KB
testcase_33 AC 3 ms
4,584 KB
testcase_34 AC 3 ms
4,492 KB
testcase_35 AC 2 ms
4,564 KB
testcase_36 AC 2 ms
4,568 KB
testcase_37 AC 3 ms
4,628 KB
testcase_38 AC 3 ms
4,576 KB
testcase_39 AC 3 ms
4,472 KB
testcase_40 AC 3 ms
4,572 KB
testcase_41 AC 3 ms
4,580 KB
testcase_42 AC 3 ms
4,560 KB
testcase_43 WA -
testcase_44 AC 3 ms
4,584 KB
testcase_45 AC 2 ms
4,480 KB
testcase_46 AC 3 ms
4,572 KB
testcase_47 AC 3 ms
4,572 KB
testcase_48 AC 2 ms
4,564 KB
testcase_49 AC 3 ms
4,512 KB
testcase_50 AC 3 ms
4,568 KB
testcase_51 AC 3 ms
4,488 KB
testcase_52 AC 3 ms
4,572 KB
testcase_53 AC 2 ms
4,516 KB
testcase_54 WA -
testcase_55 AC 2 ms
4,584 KB
testcase_56 AC 2 ms
4,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Name "main::h1" used only once: possible typo at Main.pl line 8.
Main.pl syntax OK

ソースコード

diff #

sub min{$_[0]<$_[1]?$_[0]:$_[1]}
sub max{$_[0]>$_[1]?$_[0]:$_[1]}
($d,$i,$h,$j)=<>;
exit!print $i<$h&&$j<$h||$i>$h&&$j>$h?0:-1 if $d==0;
$n=min($i,$j)==0?1e11:max(0,int(($h-min($i,$j)+$d)/$d));
$o=$h==0?1e11:max(0,int(($i-$h+$d)/$d));
$p=$h==0?1e11:max(0,int(($j-$h+$d)/$d));
$h1=max(0,$h-$d*$n);
$i1=max(0,$i-$d*$o);
$j1=max(0,$j-$d*$p);
if($i==$j){
    if($i==0){
	$n=1e11;
    }else{
	++$n;
	if($i-$d<=$h){
	    ++$n;
	    if(max(0,$h-$d)==max(0,$i-$d)){
		$n=1e11;
	    }
	}
    }
}
$o=$i1==0?1e11:$o+1 if $i1==$j1;
$n=min($n,$o+$p);
$n=-1 if $n>=1e11;
print$n
0