結果

問題 No.5 数字のブロック
ユーザー meme
提出日時 2023-04-27 22:43:53
言語 PHP
(8.3.4)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 362 bytes
コンパイル時間 1,097 ms
コンパイル使用メモリ 30,688 KB
実行使用メモリ 31,888 KB
最終ジャッジ日時 2024-04-28 11:56:17
合計ジャッジ時間 3,180 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
30,688 KB
testcase_01 AC 41 ms
30,656 KB
testcase_02 AC 38 ms
30,864 KB
testcase_03 AC 44 ms
31,376 KB
testcase_04 AC 40 ms
31,116 KB
testcase_05 AC 38 ms
31,500 KB
testcase_06 AC 38 ms
31,244 KB
testcase_07 AC 38 ms
31,188 KB
testcase_08 AC 38 ms
31,376 KB
testcase_09 AC 38 ms
31,120 KB
testcase_10 AC 40 ms
31,632 KB
testcase_11 AC 38 ms
31,248 KB
testcase_12 AC 39 ms
31,372 KB
testcase_13 AC 42 ms
31,500 KB
testcase_14 AC 39 ms
30,792 KB
testcase_15 AC 37 ms
30,968 KB
testcase_16 AC 40 ms
31,376 KB
testcase_17 AC 40 ms
31,888 KB
testcase_18 AC 43 ms
31,756 KB
testcase_19 AC 41 ms
31,888 KB
testcase_20 AC 39 ms
30,740 KB
testcase_21 AC 39 ms
30,944 KB
testcase_22 AC 38 ms
30,700 KB
testcase_23 AC 38 ms
31,036 KB
testcase_24 AC 39 ms
30,916 KB
testcase_25 AC 38 ms
30,980 KB
testcase_26 AC 39 ms
30,876 KB
testcase_27 AC 38 ms
31,104 KB
testcase_28 AC 37 ms
30,884 KB
testcase_29 AC 39 ms
31,116 KB
testcase_30 AC 38 ms
30,864 KB
testcase_31 AC 38 ms
30,584 KB
testcase_32 AC 39 ms
30,604 KB
testcase_33 AC 39 ms
30,772 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php 
	while($input = trim(fgets(STDIN))){
		$input_arr[] = $input;
	}
	
	$l = (int)$input_arr[0];
	$n = (int)$input_arr[1];
	$w_arr = array_map('intval',explode(' ', $input_arr[2]));
	
	sort($w_arr);
	
	$count = 0;
	$total = 0;
	foreach ($w_arr as $value){
		$total += $value;
		if($total <= $l){
			$count++;
		}else{
			break;
		}
	}
	
	echo $count, "\n";
?>
0