結果

問題 No.914 Omiyage
ユーザー oevloevl
提出日時 2020-04-19 18:35:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 708 bytes
コンパイル時間 1,968 ms
コンパイル使用メモリ 198,540 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 19:52:57
合計ジャッジ時間 2,597 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

const int INF = 1 << 30;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<vector<int>> A(N, vector<int>(M));
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < M; ++j) cin >> A[i][j];
    }
    vector<int> dp(K + 1, -1);
    dp[0] = 0;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < M; ++j) {
            for(int k = K; k >= 0; --k) {
                if(k - A[i][j] >= 0 and dp[i] == i) dp[k] = dp[k - A[i][j]] + 1;
            }
        }
    }
    int ans = INF;
    for(int i = 1; i <= K ; ++i) {
        if(dp[i] == N) ans = min(ans, K - i);
    }
    if(ans == INF) ans = -1;
    cout << ans << '\n';
    return 0;
}
0