結果

問題 No.5 数字のブロック
ユーザー togaerrortogaerror
提出日時 2015-04-07 00:52:02
言語 Perl
(5.38.2)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 316 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 5,452 KB
実行使用メモリ 6,248 KB
最終ジャッジ日時 2023-08-11 08:12:21
合計ジャッジ時間 1,678 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,944 KB
testcase_01 AC 4 ms
4,992 KB
testcase_02 AC 5 ms
5,016 KB
testcase_03 AC 9 ms
5,872 KB
testcase_04 AC 7 ms
5,524 KB
testcase_05 AC 11 ms
6,036 KB
testcase_06 AC 8 ms
5,552 KB
testcase_07 AC 7 ms
5,328 KB
testcase_08 AC 8 ms
5,812 KB
testcase_09 AC 6 ms
5,148 KB
testcase_10 AC 10 ms
5,900 KB
testcase_11 AC 7 ms
5,548 KB
testcase_12 AC 9 ms
5,848 KB
testcase_13 AC 10 ms
5,924 KB
testcase_14 AC 5 ms
5,092 KB
testcase_15 AC 5 ms
5,016 KB
testcase_16 AC 10 ms
6,080 KB
testcase_17 AC 11 ms
6,184 KB
testcase_18 AC 10 ms
6,004 KB
testcase_19 AC 11 ms
6,248 KB
testcase_20 AC 5 ms
4,992 KB
testcase_21 AC 5 ms
5,024 KB
testcase_22 AC 5 ms
5,136 KB
testcase_23 AC 4 ms
4,944 KB
testcase_24 AC 5 ms
4,896 KB
testcase_25 AC 5 ms
4,844 KB
testcase_26 AC 5 ms
5,080 KB
testcase_27 AC 5 ms
5,060 KB
testcase_28 AC 5 ms
5,096 KB
testcase_29 AC 7 ms
5,660 KB
testcase_30 AC 6 ms
5,056 KB
testcase_31 AC 4 ms
5,096 KB
testcase_32 AC 5 ms
4,952 KB
testcase_33 AC 5 ms
4,888 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/perl

use strict;
use warnings;

my $l = <>;
my $n =<>;
my $str = <>;
chomp $str;
my @array = split / /, $str;
my $ans = 0;
my $count = 0;
@array = sort {$a <=> $b} @array;

for(my $i = 0; $i < $n; $i++) {
	$count += $array[$i];
	if($count <= $l) {
		$ans++;
	} else {
		last;
	}
}

print "$ans\n";

exit;
0