結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー |
|
提出日時 | 2017-12-19 17:31:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 67 ms / 2,000 ms |
コード長 | 1,393 bytes |
コンパイル時間 | 2,445 ms |
コンパイル使用メモリ | 198,908 KB |
最終ジャッジ日時 | 2025-01-05 05:53:49 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h>#define VARNAME(x) #x#define show(x) cerr << #x << " = " << x << endlusing namespace std;using ll = long long;using ld = long double;template <typename T>ostream& operator<<(ostream& os, const vector<T>& v){os << "sz:" << v.size() << "\n[";for (const auto& p : v) {os << p << ",";}os << "]\n";return os;}template <typename S, typename T>ostream& operator<<(ostream& os, const pair<S, T>& p){os << "(" << p.first << "," << p.second<< ")";return os;}constexpr ll MOD = (ll)1e9 + 7LL;constexpr ld PI = static_cast<ld>(3.1415926535898);template <typename T>constexpr T INF = numeric_limits<T>::max() / 10;int main(){cin.tie(0);ios::sync_with_stdio(false);int N, K;cin >> N >> K;vector<int> A(N);for (int i = 0; i < N; i++) {cin >> A[i];}vector<bool> dp(K + 1, false);dp[0] = true;for (int i = 0; i < N; i++) {vector<bool> tmp(K + 1, false);for (int k = 0; k <= K; k++) {if (dp[k]) {tmp[k] = true;if (k + A[i] <= K) {tmp[k + A[i]] = true;}}}dp = tmp;}for (int k = K; k >= 0; k--) {if (dp[k]) {cout << k << endl;return 0;}}return 0;}