結果
| 問題 |
No.914 Omiyage
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-25 22:04:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 803 bytes |
| コンパイル時間 | 657 ms |
| コンパイル使用メモリ | 91,348 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 16:27:56 |
| 合計ジャッジ時間 | 1,329 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr int MOD = 998244353;
ll N, M, K, A[11][11], dp[11][505];
ll dfs(int n, int k) {
if(k < 0) return INF;
if(n == N) return k;
if(~dp[n][k]) return dp[n][k];
ll ret = INF;
for(int i = 0; i < M; ++i) {
ret = min(ret, dfs(n+1, k - A[n][i]));
}
return dp[n][k] = ret;
}
int main() {
cin.tie(0); ios_base::sync_with_stdio(false);
cin >> N >> M >> K;
REP(i, N) REP(j, M) cin >> A[i][j];
REP(i, 11) REP(j, 505) dp[i][j] = -1;
ll ans = dfs(0, K);
if(ans == INF) cout << -1;
else cout << dfs(0, K);
cout << '\n';
return 0;
}