結果
| 問題 | 
                            No.1701 half price
                             | 
                    
| コンテスト | |
| ユーザー | 
                             neko_the_shadow
                         | 
                    
| 提出日時 | 2021-10-10 01:12:21 | 
| 言語 | Perl  (5.40.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 514 bytes | 
| コンパイル時間 | 365 ms | 
| コンパイル使用メモリ | 6,940 KB | 
| 実行使用メモリ | 13,088 KB | 
| 最終ジャッジ日時 | 2024-09-13 15:32:20 | 
| 合計ジャッジ時間 | 6,288 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 4 TLE * 1 -- * 15 | 
コンパイルメッセージ
Main.pl syntax OK
ソースコード
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";
            
            
            
        
            
neko_the_shadow