結果

問題 No.617 Nafmo、買い出しに行く
ユーザー tenkyu9tenkyu9
提出日時 2018-03-25 20:51:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 83,792 KB
実行使用メモリ 8,596 KB
最終ジャッジ日時 2023-09-07 12:05:46
合計ジャッジ時間 2,189 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 7 ms
4,376 KB
testcase_03 AC 16 ms
4,916 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 30 ms
5,668 KB
testcase_06 AC 55 ms
8,596 KB
testcase_07 AC 55 ms
8,540 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 42 ms
6,984 KB
testcase_11 AC 55 ms
7,800 KB
testcase_12 AC 30 ms
5,560 KB
testcase_13 AC 19 ms
4,632 KB
testcase_14 AC 25 ms
4,844 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){
	
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	vector<vector<bool> > dp(n+1, vector<bool>(k+1));
	dp[0][0]=true;

	for(int i=0; i<n; i++){
		for(int j=0; j<=k; j++){
			if(!dp[i][j]){
				continue;
			}
			dp[i+1][j]=true;
			if(a[i]+j<=k){
				dp[i+1][a[i]+j]=true;
			}
		}
	}
	for(int j=k; k>=0; k--){
		if(dp[n][k]){
			cout << k << endl;
			return 0;
		}
	}

  return 0;
}
0