結果

問題 No.156 キャンディー・ボックス
ユーザー togaerror
提出日時 2015-03-13 02:49:51
言語 Perl
(5.40.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 327 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 5,632 KB
実行使用メモリ 5,760 KB
最終ジャッジ日時 2024-06-28 22:49:13
合計ジャッジ時間 1,547 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 25 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/perl

use strict;
use warnings;

my ($n, $m) = split / /, <>;
my $c = <>;
chomp $c;

my @array = split / /, $c;
@array = sort @array;
my $total = 0;

for(my $i = 0; $i < $n; $i++) {
	$total += $array[$i];
	if($total == $m) {
		print $i + 1 . "\n";
		last;
	} elsif($total > $m) {
		print "$i\n";
		last;
	}
}

exit;
0