結果

問題 No.1701 half price
ユーザー neko_the_shadowneko_the_shadow
提出日時 2021-10-10 01:12:21
言語 Perl
(5.38.2)
結果
TLE  
実行時間 -
コード長 514 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 8,736 KB
最終ジャッジ日時 2023-10-11 16:52:52
合計ジャッジ時間 6,652 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,432 KB
testcase_01 AC 7 ms
5,248 KB
testcase_02 AC 694 ms
5,132 KB
testcase_03 AC 7 ms
5,060 KB
testcase_04 AC 698 ms
5,084 KB
testcase_05 AC 12 ms
5,384 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

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

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

my %visited;
for (my $bit = 0; $bit < 3**$n; $bit++) {
    
    my $sum = 0;
    my $x = $bit;
    my $key = 0;
    for (my $i = 0; $i < $n; $i++) {
        my $y = $x % 3;
        $x /= 3;

        $sum += $a[$i]   if ($y == 1);
        $sum += $a[$i]/2 if ($y == 2);
        $key |= 1 << $i  if ($y != 0);
    }
    $visited{$key} = 1 if ($sum == $w);
}

my $ans = keys %visited;
print "$ans\n";
0