結果

問題 No.617 Nafmo、買い出しに行く
ユーザー ふっぴーふっぴー
提出日時 2017-12-17 13:45:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,129 bytes
コンパイル時間 1,436 ms
コンパイル使用メモリ 169,960 KB
実行使用メモリ 175,176 KB
最終ジャッジ日時 2023-08-22 04:22:08
合計ジャッジ時間 3,610 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
81,068 KB
testcase_01 AC 16 ms
42,156 KB
testcase_02 AC 43 ms
104,520 KB
testcase_03 AC 63 ms
143,660 KB
testcase_04 AC 26 ms
65,572 KB
testcase_05 AC 73 ms
151,436 KB
testcase_06 AC 97 ms
175,176 KB
testcase_07 AC 97 ms
175,032 KB
testcase_08 AC 11 ms
26,392 KB
testcase_09 AC 12 ms
34,288 KB
testcase_10 AC 92 ms
174,896 KB
testcase_11 AC 101 ms
175,024 KB
testcase_12 AC 82 ms
174,952 KB
testcase_13 AC 75 ms
174,856 KB
testcase_14 AC 88 ms
174,896 KB
testcase_15 AC 65 ms
175,176 KB
testcase_16 AC 63 ms
174,916 KB
testcase_17 AC 64 ms
175,164 KB
testcase_18 AC 10 ms
26,516 KB
testcase_19 AC 9 ms
26,608 KB
testcase_20 AC 13 ms
34,148 KB
testcase_21 AC 18 ms
49,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	int n, k, i, j;
	cin >> n >> k;
	vi a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	vii dp(n + 1, vi(2000020));
	dp[0][0] = 1;
	for (i = 0; i < n; i++) {
		for (j = 0; j <= k; j++) {
			if (dp[i][j]) {
				dp[i + 1][j] = 1;
				dp[i + 1][j + a[i]] = 1;
			}
		}
	}
	for (j = k; j >= 0; j--) {
		if (dp[n][j]) {
			cout << j << endl;
			return 0;
		}
	}
}
0