結果

問題 No.266 最終進化を目指せ
ユーザー tailstails
提出日時 2015-08-07 23:51:48
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 346 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 5,276 KB
実行使用メモリ 4,828 KB
最終ジャッジ日時 2023-09-25 06:29:21
合計ジャッジ時間 1,381 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 3 ms
4,664 KB
testcase_02 AC 3 ms
4,696 KB
testcase_03 AC 2 ms
4,660 KB
testcase_04 AC 3 ms
4,552 KB
testcase_05 AC 3 ms
4,792 KB
testcase_06 AC 3 ms
4,492 KB
testcase_07 AC 2 ms
4,624 KB
testcase_08 AC 3 ms
4,560 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 3 ms
4,692 KB
testcase_12 WA -
testcase_13 AC 3 ms
4,512 KB
testcase_14 AC 3 ms
4,688 KB
testcase_15 AC 3 ms
4,680 KB
testcase_16 AC 3 ms
4,824 KB
testcase_17 AC 3 ms
4,792 KB
testcase_18 WA -
testcase_19 AC 3 ms
4,668 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 3 ms
4,668 KB
testcase_23 AC 3 ms
4,772 KB
testcase_24 AC 3 ms
4,508 KB
testcase_25 AC 2 ms
4,636 KB
testcase_26 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

$n=<>;
@s=<>=~/\d+/g;

sub f{
    my($n,$k)=@_;
    return $d{$n,$k} if $d{$n,$k};
    return $d{$n,$k}=$k+1 if $n<1;
    return $d{$n,$k}=f($n-1,$k)+1 if $k<=$s[$n-1];
    my $b=1e99;
    for(0..$s[$n-1]/2){
	my $t=f($n,$_)+f($n,$k-$_-1);
	$b=$t if $b>$t;
    }
    return $d{$n,$k}=$b;
}

for$k(0..$s[$n]){
    print f($n,$k),$k<$s[$n]?$":$/;
}
0