結果

問題 No.617 Nafmo、買い出しに行く
ユーザー yansi819yansi819
提出日時 2024-03-30 16:56:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 667 bytes
コンパイル時間 4,377 ms
コンパイル使用メモリ 262,344 KB
実行使用メモリ 44,616 KB
最終ジャッジ日時 2024-03-30 16:57:01
合計ジャッジ時間 5,783 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
20,040 KB
testcase_01 AC 3 ms
9,800 KB
testcase_02 AC 11 ms
26,184 KB
testcase_03 AC 25 ms
36,424 KB
testcase_04 AC 5 ms
15,944 KB
testcase_05 AC 42 ms
38,472 KB
testcase_06 AC 100 ms
44,616 KB
testcase_07 AC 101 ms
44,616 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
7,752 KB
testcase_10 AC 75 ms
44,616 KB
testcase_11 AC 87 ms
44,616 KB
testcase_12 AC 60 ms
44,616 KB
testcase_13 AC 35 ms
44,616 KB
testcase_14 AC 42 ms
44,616 KB
testcase_15 AC 9 ms
42,568 KB
testcase_16 AC 8 ms
42,568 KB
testcase_17 AC 9 ms
42,568 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
7,752 KB
testcase_21 AC 3 ms
11,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

int N, K;
bool dp[25][2020202];
int A[25];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> A[i];
  dp[0][0] = true;
  for (int j = 0; j <= K; j++) {
    for (int i = 0; i < N; i++) {
      dp[i + 1][j] = dp[i][j]; 
      if (j - A[i] >= 0 && dp[i][j - A[i]]) dp[i + 1][j] = true;
    }
  }
  //for (int i = 0; i <= N; i++) {
  //  for (int j = 0; j <= K; j++) cout << dp[i][j] << " \n"[j == K];
  //}
  int ans = 0;
  for (int i = 0; i <= K; i++) if (dp[N][i]) ans = i;
  cout << ans << endl;
  return 0;
}
0