結果

問題 No.914 Omiyage
ユーザー otamay6
提出日時 2019-10-25 21:24:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 666 bytes
コンパイル時間 1,761 ms
コンパイル使用メモリ 176,888 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 16:21:16
合計ジャッジ時間 2,315 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N,M,K;cin>>N>>M>>K;
    vector<vector<int>> A(N,vector<int>(M));
    REP(i,N) REP(j,M) cin>>A[i][j];
    vector<vector<bool>> dp(N+1,vector<bool>(K+1,false));
    dp[0][K]=true;
    REP(i,N) REP(j,K+1){
        REP(k,M){
            if(j-A[i][k]>=0) dp[i+1][j-A[i][k]]=dp[i+1][j-A[i][k]]|dp[i][j];
        }
    }
    int ans=K+1;
    REP(i,K+1) if(dp[N][i]) ans=min(ans,i);
    if(ans==K+1) cout<<-1<<endl;
    else cout<<ans<<endl;
}
0