結果
問題 | No.1701 half price |
ユーザー |
![]() |
提出日時 | 2021-10-10 00:33:27 |
言語 | Perl (5.40.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 430 bytes |
コンパイル時間 | 46 ms |
コンパイル使用メモリ | 6,812 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-13 14:48:54 |
合計ジャッジ時間 | 1,163 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 12 |
コンパイルメッセージ
Main.pl syntax OK
ソースコード
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";