結果

問題 No.617 Nafmo、買い出しに行く
ユーザー motimoti
提出日時 2018-05-20 15:16:12
言語 Perl
(5.38.2)
結果
TLE  
実行時間 -
コード長 452 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 5,260 KB
実行使用メモリ 9,368 KB
最終ジャッジ日時 2023-09-11 00:02:20
合計ジャッジ時間 4,185 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
9,180 KB
testcase_01 AC 5 ms
5,032 KB
testcase_02 AC 10 ms
4,896 KB
testcase_03 AC 178 ms
5,072 KB
testcase_04 AC 5 ms
4,912 KB
testcase_05 AC 361 ms
4,884 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 #

#/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";
0