結果

問題 No.914 Omiyage
ユーザー auauaauaua
提出日時 2019-10-25 21:40:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,005 bytes
コンパイル時間 1,512 ms
コンパイル使用メモリ 164,844 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 21:13:50
合計ジャッジ時間 2,269 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,m,k;cin>>n>>m>>k;
    vector<vector<ll> >a(n+1,vector<ll>(m));
    rep(i,n)rep(j,m)cin>>a[i+1][j];
    ll mi=k;
    vector<vector<ll> >dp(n+1,vector<ll>(k+1));
    dp[0][k]=1;
    bool ff=1;
    REP(i,1,n+1){
        bool f=0;
        rep(j,k+1){
            rep(s,m){
                if(j+a[i][s]<=k&&dp[i-1][j+a[i][s]]){
                    dp[i][j]=dp[i-1][j+a[i][s]];
                    f=1;
                }
            }
        }
        if(f==0){
            ff=0;
            break;
        }
    }
    rep(i,k+1){
        if(dp[n][i]){
            mi=i;
            break;
        }
    }
    cout<<(ff?mi:-1)<<endl;
}
0