結果
| 問題 |
No.914 Omiyage
|
| コンテスト | |
| ユーザー |
ScottShelby
|
| 提出日時 | 2020-10-04 17:53:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 705 bytes |
| コンパイル時間 | 1,928 ms |
| コンパイル使用メモリ | 175,296 KB |
| 実行使用メモリ | 16,960 KB |
| 最終ジャッジ日時 | 2024-07-19 17:34:07 |
| 合計ジャッジ時間 | 8,525 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 17 |
ソースコード
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;
int n, m, k;
vector<vector<int>> a;
int dfs(int depth, int money) {
if (money < 0) return INF;
if (depth == n) return money;
int res = INF;
rep(i, m) {
int ncost = money - a[depth][i];
chmin(res, dfs(depth + 1, ncost));
}
return res;
}
int main() {
cin >> n >> m >> k;
a.resize(n, vector<int>(m));
rep(i, n) rep(j, m) {
cin >> a[i][j];
}
int ans = dfs(0, k);
if (ans == INF) ans = -1;
cout << ans << endl;
}
ScottShelby