結果

問題 No.5 数字のブロック
ユーザー beatdjam
提出日時 2016-09-21 17:14:43
言語 PHP
(843.2)
結果
AC  
実行時間 49 ms / 5,000 ms
コード長 664 bytes
コンパイル時間 4,083 ms
コンパイル使用メモリ 31,828 KB
実行使用メモリ 32,528 KB
最終ジャッジ日時 2024-11-18 09:31:27
合計ジャッジ時間 4,888 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

        $input_lines = trim(fgets(STDIN));
        $input_lines = str_replace(array("\r\n","\r","\n"), "", $input_lines);
        do {
            $tmpStr[] = $input_lines;
            $input_lines = trim(fgets(STDIN));
            $input_lines = str_replace(array("\r\n","\r","\n"), "", $input_lines);
        } while ($input_lines !== "");
        
        $max = $tmpStr[0];
        $boxes = explode(" ",$tmpStr[2]);
        sort($boxes);
        
        $tmp = 0;
        $count = count($boxes);
        for($i = 0;$i < $count;$i++){
        	$tmp += $boxes[$i];
        	if($tmp > $max){
        		break;
        	}
        }
        
        echo $i;
0