結果

問題 No.914 Omiyage
ユーザー mino_yellowmino_yellow
提出日時 2022-11-16 01:24:48
言語 PHP
(8.3.4)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 790 ms
コンパイル使用メモリ 32,784 KB
実行使用メモリ 32,884 KB
最終ジャッジ日時 2023-10-17 00:08:59
合計ジャッジ時間 3,879 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
32,884 KB
testcase_01 AC 43 ms
32,884 KB
testcase_02 AC 42 ms
32,884 KB
testcase_03 AC 43 ms
32,884 KB
testcase_04 AC 42 ms
32,884 KB
testcase_05 AC 41 ms
32,884 KB
testcase_06 AC 42 ms
32,884 KB
testcase_07 AC 42 ms
32,884 KB
testcase_08 AC 42 ms
32,884 KB
testcase_09 AC 42 ms
32,884 KB
testcase_10 AC 42 ms
32,884 KB
testcase_11 AC 42 ms
32,884 KB
testcase_12 AC 42 ms
32,884 KB
testcase_13 AC 42 ms
32,884 KB
testcase_14 AC 42 ms
32,884 KB
testcase_15 AC 42 ms
32,884 KB
testcase_16 AC 41 ms
32,884 KB
testcase_17 AC 41 ms
32,884 KB
testcase_18 AC 41 ms
32,884 KB
testcase_19 AC 41 ms
32,884 KB
testcase_20 AC 41 ms
32,884 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
fscanf(STDIN,"%d%d%d",$N,$M,$K);
for($i=0;$i<$N;++$i) $a[$i] = array_map('intval',explode(" ", trim(fgets(STDIN))));

$old[0] = true;
for($i=0;$i<$N;++$i){
    $new = [];
    for($j=0;$j<$M;++$j){
        foreach($old as $p => $v){
            if($a[$i][$j]+$p <= $K) $new[$a[$i][$j]+$p] = true;
        }
    }
    $old = $new;
}
if(count($new) == 0) echo -1 . PHP_EOL;
else echo $K - max(array_keys($new)) . PHP_EOL;

?>
0