結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー |
![]() |
提出日時 | 2018-05-20 15:16:12 |
言語 | Perl (5.40.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 452 bytes |
コンパイル時間 | 30 ms |
コンパイル使用メモリ | 6,688 KB |
実行使用メモリ | 13,756 KB |
最終ジャッジ日時 | 2024-06-28 14:41:12 |
合計ジャッジ時間 | 4,055 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | AC * 6 TLE * 1 -- * 13 |
コンパイルメッセージ
Main.pl syntax OK
ソースコード
#/usr/bin/env perl use strict; use warnings; my ($n, $k) = split / /, <>; chomp $k; my %dp; my @vs; for ($_ = 0; $_ < $n; $_++) { my $m = <>; chomp$m; push @vs, $m; } $dp{0} = 1; my $ma = 0; for (my $s = 0; $s < (1 << $n); $s++) { my $weight = 0; for (my $i = 0; $i < $n; $i++) { if (($s | (1 << $i)) == $s) { $weight += $vs[$i]; if ($weight <= $k) { $ma = $weight if $ma < $weight; } } } } print "$ma\n";