結果

問題 No.5 数字のブロック
ユーザー しめはじめしめはじめ
提出日時 2019-06-04 10:19:54
言語 PHP
(8.3.4)
結果
AC  
実行時間 81 ms / 5,000 ms
コード長 365 bytes
コンパイル時間 907 ms
コンパイル使用メモリ 32,544 KB
実行使用メモリ 32,636 KB
最終ジャッジ日時 2023-10-17 23:37:46
合計ジャッジ時間 2,801 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

<?php
$box = trim( fgets( STDIN ) );
$num = trim( fgets( STDIN ) );
$data = explode( " ", trim( fgets( STDIN ) ) );
$fill = 0;
$idx = 0;
// 小さなもの順でソート
sort( $data );
foreach( $data as $w ){
    //あふれたら終わり
    if( ( $fill += $w ) > $box ){
        break;
    }
    // ブロックを数える
    $idx++;
}
printf( "%d\n", $idx );
0