結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,552 KB
testcase_01 AC 3 ms
5,552 KB
testcase_02 AC 3 ms
5,552 KB
testcase_03 AC 8 ms
6,932 KB
testcase_04 AC 7 ms
6,652 KB
testcase_05 AC 9 ms
7,320 KB
testcase_06 AC 7 ms
6,692 KB
testcase_07 AC 7 ms
6,496 KB
testcase_08 AC 8 ms
6,848 KB
testcase_09 AC 5 ms
6,008 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 AC 3 ms
5,604 KB
testcase_16 AC 10 ms
7,368 KB
testcase_17 AC 10 ms
7,680 KB
testcase_18 AC 10 ms
7,540 KB
testcase_19 AC 11 ms
7,792 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++){
    if($sum + $sorted_weight_blocks[$num] == $weight_box){
        $count++;
        last;
    }{
    $sum += $sorted_weight_blocks[$num];
    }
    $count++;
}

print "$count\n"
0