結果

問題 No.281 門松と魔法(1)
ユーザー tailstails
提出日時 2015-09-19 00:01:49
言語 Perl
(5.38.2)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 565 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-24 11:44:09
合計ジャッジ時間 1,468 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,376 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,504 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,504 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,504 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 3 ms
5,504 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,504 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 3 ms
5,504 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 3 ms
5,504 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 3 ms
5,504 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 2 ms
5,504 KB
testcase_28 AC 3 ms
5,504 KB
testcase_29 AC 2 ms
5,504 KB
testcase_30 AC 3 ms
5,504 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 3 ms
5,504 KB
testcase_33 AC 2 ms
5,504 KB
testcase_34 AC 3 ms
5,376 KB
testcase_35 AC 3 ms
5,376 KB
testcase_36 AC 2 ms
5,504 KB
testcase_37 AC 3 ms
5,504 KB
testcase_38 AC 3 ms
5,504 KB
testcase_39 AC 3 ms
5,632 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 3 ms
5,376 KB
testcase_43 WA -
testcase_44 AC 3 ms
5,504 KB
testcase_45 AC 3 ms
5,376 KB
testcase_46 AC 3 ms
5,504 KB
testcase_47 AC 2 ms
5,504 KB
testcase_48 AC 3 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 3 ms
5,504 KB
testcase_51 AC 3 ms
5,376 KB
testcase_52 AC 2 ms
5,504 KB
testcase_53 AC 3 ms
5,504 KB
testcase_54 WA -
testcase_55 AC 3 ms
5,504 KB
testcase_56 AC 3 ms
5,376 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