結果

問題 No.914 Omiyage
ユーザー tkmst201tkmst201
提出日時 2019-10-25 21:26:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,005 bytes
コンパイル時間 1,218 ms
コンパイル使用メモリ 144,156 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 05:08:40
合計ジャッジ時間 1,960 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N, M, K;
int A[10][10];
bool dp[10][501];

int main() {
	cin >> N >> M >> K;
	REP(i, N) REP(j, M) scanf("%d", &A[i][j]);
	
	
	dp[0][0] = true;
	REP(i, N) REP(j, 501) if (dp[i][j]) {
		REP(k, M) if (j + A[i][k] < 501) {
			dp[i + 1][j + A[i][k]] = true;
		}
	}
	
	int ans = -1;
	REP(i, K + 1) if (dp[N][i]) ans = i;
	if (ans == -1) cout << -1 << endl;
	else cout << K - ans << endl;
	
	return 0;
}
0