結果

問題 No.5 数字のブロック
ユーザー michirumichiru
提出日時 2019-11-16 19:49:32
言語 PHP
(8.3.4)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 336 bytes
コンパイル時間 5,094 ms
コンパイル使用メモリ 31,988 KB
実行使用メモリ 32,496 KB
最終ジャッジ日時 2023-10-25 08:59:41
合計ジャッジ時間 8,055 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
32,436 KB
testcase_01 AC 43 ms
32,436 KB
testcase_02 AC 44 ms
32,372 KB
testcase_03 AC 48 ms
32,496 KB
testcase_04 AC 48 ms
32,496 KB
testcase_05 AC 51 ms
32,496 KB
testcase_06 AC 48 ms
32,496 KB
testcase_07 AC 48 ms
32,496 KB
testcase_08 AC 49 ms
32,496 KB
testcase_09 AC 46 ms
32,496 KB
testcase_10 AC 51 ms
32,496 KB
testcase_11 AC 47 ms
32,496 KB
testcase_12 AC 49 ms
32,496 KB
testcase_13 AC 50 ms
32,496 KB
testcase_14 AC 44 ms
32,496 KB
testcase_15 AC 44 ms
32,496 KB
testcase_16 AC 51 ms
32,496 KB
testcase_17 AC 52 ms
32,496 KB
testcase_18 AC 52 ms
32,496 KB
testcase_19 AC 53 ms
32,496 KB
testcase_20 AC 44 ms
32,372 KB
testcase_21 AC 44 ms
32,432 KB
testcase_22 AC 43 ms
32,372 KB
testcase_23 AC 44 ms
32,496 KB
testcase_24 AC 44 ms
32,496 KB
testcase_25 AC 44 ms
32,496 KB
testcase_26 AC 44 ms
32,372 KB
testcase_27 AC 43 ms
32,372 KB
testcase_28 AC 44 ms
32,372 KB
testcase_29 AC 47 ms
32,496 KB
testcase_30 AC 45 ms
32,496 KB
testcase_31 AC 43 ms
32,372 KB
testcase_32 AC 44 ms
32,372 KB
testcase_33 AC 43 ms
32,372 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$box = trim(fgets(STDIN));
$num = trim(fgets(STDIN));
$blocks = explode(" ", (trim(fgets(STDIN))));

sort($blocks);
$ans;$totalBlockSize = 0;
if ($box < array_sum($blocks)){
    for ($i=0; $box >= $totalBlockSize; $i++) {
        $totalBlockSize += $blocks[$i];
    }
    $ans = $i - 1;
} else {
    $ans = $num;
}
echo $ans."\n";
0