結果

問題 No.5 数字のブロック
ユーザー shiCanoko_oshiCanoko_o
提出日時 2019-05-23 19:04:22
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 48 ms
コンパイル使用メモリ 5,436 KB
実行使用メモリ 9,808 KB
最終ジャッジ日時 2023-10-17 11:34:05
合計ジャッジ時間 7,513 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,552 KB
testcase_01 AC 3 ms
5,552 KB
testcase_02 WA -
testcase_03 AC 8 ms
6,932 KB
testcase_04 AC 7 ms
6,648 KB
testcase_05 WA -
testcase_06 AC 8 ms
6,696 KB
testcase_07 AC 6 ms
6,496 KB
testcase_08 AC 8 ms
6,848 KB
testcase_09 AC 5 ms
6,004 KB
testcase_10 AC 10 ms
7,476 KB
testcase_11 AC 6 ms
6,468 KB
testcase_12 AC 8 ms
6,988 KB
testcase_13 AC 9 ms
7,296 KB
testcase_14 AC 3 ms
5,572 KB
testcase_15 WA -
testcase_16 AC 10 ms
7,368 KB
testcase_17 AC 11 ms
7,676 KB
testcase_18 AC 10 ms
7,540 KB
testcase_19 AC 12 ms
7,788 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

my $weight_box = <>;#箱の幅
my $total_blocks = <>;#ブロックの数
my $weight_blocks = <>;#各ブロックの幅
chomp ($weight_box, $total_blocks, $weight_blocks);

my @blocks = split (/ /, $weight_blocks);#各ブロックを配列に入れる
my @sorted_weight_blocks = sort{$a <=> $b}@blocks;#配列に入れたブロックを小さい順に並べる

my $sum = 0;
my $count = 0;

for (my $num = 0; $sum + $sorted_weight_blocks[$num]< $weight_box; $num++){
    $sum += $sorted_weight_blocks[$num];
    $count++;
}

print "$count\n"
0