結果

問題 No.5 数字のブロック
ユーザー mahna
提出日時 2020-10-01 17:11:59
言語 PHP
(843.2)
結果
AC  
実行時間 49 ms / 5,000 ms
コード長 388 bytes
コンパイル時間 2,877 ms
コンパイル使用メモリ 32,148 KB
実行使用メモリ 32,660 KB
最終ジャッジ日時 2024-07-07 01:26:20
合計ジャッジ時間 5,387 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
// Your code here!

    $all_length = trim(fgets(STDIN));
    $num = trim(fgets(STDIN));
    $length_arr = explode(" ",trim(fgets(STDIN)));
    sort($length_arr);
    
    $ct = 0;
    for($i = 0; $i < count($length_arr); $i++) {
        if ($all_length - $length_arr[$i] >= 0) {
            $all_length -= $length_arr[$i];
            $ct++;
        }
    }
    
    echo $ct;

?>
0