結果
問題 | No.617 Nafmo、買い出しに行く |
ユーザー |
![]() |
提出日時 | 2017-12-17 14:41:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 825 bytes |
コンパイル時間 | 2,143 ms |
コンパイル使用メモリ | 193,668 KB |
最終ジャッジ日時 | 2025-01-05 05:51:04 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include "bits/stdc++.h"#define rep(a,b) for(int a = 0;a < b;a++)#define REP(i, x, n) for(int i = x; i < n; i++)#define P(a) cout << a << endl#define MP(a,b) make_pair(a,b)#define PB(a) push_back(a)using namespace std;typedef long long ll;typedef unsigned long long ull;typedef vector<int> vi;int dx[] = { 1, -1 , 0 , 0 };int dy[] = { 0, 0, 1, -1 };ll MOD = 1000000007;int dp[2000000];void solve() {int n,k;cin >> n >> k;rep(i,k+1)dp[i] = -1;dp[0] = 1;rep(i,n){int a;cin >> a;for(int j = k+1;j >= 0;j--){if(dp[j] == 1){dp[j+a] = 1;}}}int ans = -1;rep(i,k+1){if(dp[i] != -1){ans = i;}}cout << ans << endl;}int main() {solve();return 0;}