結果

問題 No.156 キャンディー・ボックス
ユーザー kurokitsunekurokitsune
提出日時 2015-03-31 04:19:17
言語 PHP
(8.2.11)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 402 bytes
コンパイル時間 557 ms
コンパイル使用メモリ 18,776 KB
実行使用メモリ 19,036 KB
最終ジャッジ日時 2023-09-17 00:33:36
合計ジャッジ時間 2,636 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 15 ms
18,908 KB
testcase_02 AC 15 ms
18,972 KB
testcase_03 AC 15 ms
18,844 KB
testcase_04 AC 16 ms
18,944 KB
testcase_05 AC 16 ms
18,980 KB
testcase_06 AC 15 ms
18,984 KB
testcase_07 AC 15 ms
18,996 KB
testcase_08 AC 15 ms
18,948 KB
testcase_09 AC 16 ms
18,988 KB
testcase_10 AC 15 ms
18,988 KB
testcase_11 AC 15 ms
18,860 KB
testcase_12 AC 16 ms
18,976 KB
testcase_13 AC 15 ms
18,976 KB
testcase_14 AC 15 ms
18,972 KB
testcase_15 AC 15 ms
18,988 KB
testcase_16 AC 15 ms
18,988 KB
testcase_17 AC 16 ms
18,936 KB
testcase_18 WA -
testcase_19 AC 15 ms
18,852 KB
testcase_20 WA -
testcase_21 AC 16 ms
18,972 KB
testcase_22 AC 16 ms
19,032 KB
testcase_23 AC 16 ms
18,740 KB
testcase_24 AC 16 ms
18,860 KB
testcase_25 AC 16 ms
18,884 KB
testcase_26 AC 16 ms
19,000 KB
testcase_27 AC 16 ms
18,968 KB
testcase_28 AC 16 ms
18,836 KB
testcase_29 AC 15 ms
18,808 KB
testcase_30 AC 15 ms
18,988 KB
testcase_31 AC 15 ms
18,952 KB
testcase_32 AC 15 ms
18,944 KB
testcase_33 AC 16 ms
19,036 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$num_array = explode(" ", fgets(STDIN));
$box_num = $num_array[0];
$need_candy_num = $num_array[1];
$candy_num = explode(" ", fgets(STDIN));

sort($candy_num);
$candy_have = 0;
$count = 0;
for($i=0; $i<$box_num; $i++){
    if($candy_have < $need_candy_num){
        $candy_have += $candy_num[$i];
        if($candy_have <= $need_candy_num){
            $count++;
        }
    }
}
echo $count;
?>
0