結果

問題 No.5 数字のブロック
ユーザー PcclaPccla
提出日時 2017-07-13 01:22:05
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 468 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 31,064 KB
実行使用メモリ 31,884 KB
最終ジャッジ日時 2024-04-16 17:55:06
合計ジャッジ時間 2,729 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
31,164 KB
testcase_01 AC 47 ms
31,116 KB
testcase_02 AC 46 ms
31,144 KB
testcase_03 AC 53 ms
30,988 KB
testcase_04 AC 47 ms
31,396 KB
testcase_05 WA -
testcase_06 AC 47 ms
31,416 KB
testcase_07 AC 45 ms
31,400 KB
testcase_08 AC 46 ms
31,316 KB
testcase_09 AC 42 ms
31,412 KB
testcase_10 AC 48 ms
31,884 KB
testcase_11 AC 44 ms
31,244 KB
testcase_12 AC 45 ms
31,140 KB
testcase_13 AC 47 ms
31,500 KB
testcase_14 AC 41 ms
31,148 KB
testcase_15 WA -
testcase_16 AC 48 ms
31,312 KB
testcase_17 AC 50 ms
31,756 KB
testcase_18 AC 49 ms
31,756 KB
testcase_19 AC 50 ms
31,884 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 41 ms
31,228 KB
testcase_24 AC 41 ms
31,328 KB
testcase_25 AC 41 ms
31,032 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$box_length = trim(fgets(STDIN));
$block_num = trim(fgets(STDIN));
$block = trim(fgets(STDIN));

$block_arr = explode(" ", $block);
$block_arr_sort = sort($block_arr);

$block_length = $block_arr[0];

if ($block_arr[0] === $box_length)
{
    echo 1;
}
elseif ($block_arr[0] > $box_length)
{
    echo 0;
}
else
{
	for ($i = 1; $i < $block_num; $i++)
	{
		$block_length += $block_arr[$i];
		if ($block_length >= $box_length)
		{
			echo $i."\n";
			break;
		}
	}
}
0