結果
| 問題 | No.617 Nafmo、買い出しに行く | 
| コンテスト | |
| ユーザー |  tenkyu9 | 
| 提出日時 | 2018-03-25 20:51:17 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 56 ms / 2,000 ms | 
| コード長 | 687 bytes | 
| コンパイル時間 | 792 ms | 
| コンパイル使用メモリ | 87,936 KB | 
| 実行使用メモリ | 8,704 KB | 
| 最終ジャッジ日時 | 2024-06-25 06:11:53 | 
| 合計ジャッジ時間 | 1,957 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 20 | 
ソースコード
#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;
}
            
            
            
        