結果
問題 |
No.914 Omiyage
|
ユーザー |
|
提出日時 | 2019-10-27 06:19:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 598 bytes |
コンパイル時間 | 2,397 ms |
コンパイル使用メモリ | 198,412 KB |
最終ジャッジ日時 | 2025-01-08 01:59:24 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; vector<vector<bool>> dp(n + 1, vector<bool>(k + 1)); dp[0][0] = true; for (int i = 1; i <= n; i++) { for (int j = 0; j < m; j++) { int x; cin >> x; for (int u = 0; u <= k; u++) { if (u - x >= 0) if (dp[i - 1][u - x]) dp[i][u] = true; } } } for (int i = k; i > 1; i--) { if (dp[n][i]) { cout << k - i << '\n'; return 0; } } cout << -1 << '\n'; return 0; }