結果

問題 No.156 キャンディー・ボックス
ユーザー kurokitsunekurokitsune
提出日時 2015-03-31 04:21:35
言語 PHP
(8.3.4)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 407 bytes
コンパイル時間 74 ms
コンパイル使用メモリ 18,820 KB
実行使用メモリ 19,136 KB
最終ジャッジ日時 2023-09-17 00:33:42
合計ジャッジ時間 1,558 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 14 ms
18,912 KB
testcase_02 AC 13 ms
18,896 KB
testcase_03 AC 12 ms
18,876 KB
testcase_04 AC 13 ms
19,032 KB
testcase_05 AC 13 ms
18,980 KB
testcase_06 AC 13 ms
18,836 KB
testcase_07 AC 12 ms
19,072 KB
testcase_08 AC 13 ms
19,048 KB
testcase_09 AC 13 ms
18,956 KB
testcase_10 AC 13 ms
18,980 KB
testcase_11 AC 12 ms
18,932 KB
testcase_12 AC 13 ms
18,932 KB
testcase_13 AC 13 ms
18,980 KB
testcase_14 AC 13 ms
18,924 KB
testcase_15 AC 13 ms
18,984 KB
testcase_16 AC 13 ms
18,928 KB
testcase_17 AC 13 ms
18,828 KB
testcase_18 WA -
testcase_19 AC 12 ms
18,980 KB
testcase_20 WA -
testcase_21 AC 12 ms
18,904 KB
testcase_22 AC 12 ms
18,928 KB
testcase_23 AC 13 ms
18,872 KB
testcase_24 AC 13 ms
18,980 KB
testcase_25 AC 13 ms
18,988 KB
testcase_26 AC 13 ms
19,024 KB
testcase_27 AC 12 ms
18,984 KB
testcase_28 AC 13 ms
18,980 KB
testcase_29 AC 13 ms
18,912 KB
testcase_30 AC 12 ms
18,844 KB
testcase_31 AC 13 ms
19,060 KB
testcase_32 AC 13 ms
18,804 KB
testcase_33 AC 13 ms
18,984 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."\n";
?>
0