結果
| 問題 | 
                            No.1701 half price
                             | 
                    
| コンテスト | |
| ユーザー | 
                             neko_the_shadow
                         | 
                    
| 提出日時 | 2021-10-10 00:33:11 | 
| 言語 | Perl  (5.40.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 444 bytes | 
| コンパイル時間 | 242 ms | 
| コンパイル使用メモリ | 6,940 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-09-13 14:48:38 | 
| 合計ジャッジ時間 | 1,526 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 2 | 
| other | WA * 20 | 
コンパイルメッセージ
Main.pl syntax OK
ソースコード
use utf8;
use strict;
use warnings;
use List::Util qw/sum/;
my ($n, $w) = split / /, <>;
my @a = split / /, <>;
print "@a\n";
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";
            
            
            
        
            
neko_the_shadow