結果

問題 No.914 Omiyage
ユーザー kuhakukuhaku
提出日時 2019-10-25 21:38:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 984 bytes
コンパイル時間 2,609 ms
コンパイル使用メモリ 171,544 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 21:13:19
合計ジャッジ時間 3,015 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 2 ms
4,372 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 AC 2 ms
4,372 KB
testcase_14 AC 2 ms
4,372 KB
testcase_15 AC 2 ms
4,372 KB
testcase_16 AC 2 ms
4,372 KB
testcase_17 AC 2 ms
4,372 KB
testcase_18 AC 2 ms
4,372 KB
testcase_19 AC 2 ms
4,372 KB
testcase_20 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define rep(i, n) FOR(i, 0, n)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

bool dp[10][501] = {};

int main(void){
	int n, m, k;
	cin >> n >> m >> k;

	vector<vector<int> > a(n, vector<int>(m));
	rep(i, n){
		rep(j, m) cin >> a[i][j];
	}

	rep(i, m){
		if(a[0][i] <= k){
			dp[0][a[0][i]] = true;
		}
	}
	FOR(i, 1, n){
		rep(j, m){
			rep(h, k-a[i][j]+1){
				if(dp[i-1][h]){
					dp[i][h+a[i][j]] = true;
				}
			}
		}
	}

/*
	rep(i, n){
		rep(j, k) cosp(dp[i][j]);
		cout << endl;
	}
*/

	for(int i = k; i > 0; i--){
		if(dp[n-1][i]){
			co(k-i);
			return 0;
		}
	}

	co(-1);
	return 0;
}
0