結果

問題 No.1701 half price
ユーザー neko_the_shadowneko_the_shadow
提出日時 2021-10-10 00:33:27
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 430 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 5,460 KB
最終ジャッジ日時 2023-10-11 16:04:09
合計ジャッジ時間 1,853 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,184 KB
testcase_01 AC 7 ms
5,268 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 7 ms
5,328 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 6 ms
5,400 KB
testcase_10 AC 7 ms
5,320 KB
testcase_11 WA -
testcase_12 AC 7 ms
5,180 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 7 ms
5,316 KB
testcase_16 AC 7 ms
5,408 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 7 ms
5,284 KB
testcase_21 AC 49 ms
5,400 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

use utf8;
use strict;
use warnings;
use List::Util qw/sum/;

my ($n, $w) = split / /, <>;
my @a = split / /, <>;

my $ans = 0;
for (my $bit = 1; $bit < (1<<$n); $bit++) {
    my @prices = map $a[$_], grep {$bit& (1<<$_)} 0..$n-1;

    my $sum1 = sum @prices;
    $ans++ if ($sum1 == $w);
    for (my $i = 0; $i < @prices; $i++) {
        my $sum2 = $sum1 - $prices[$i] / 2;
        $ans++ if ($sum2 == $w);
    }
}
print "$ans\n";
0