結果

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

ソースコード

diff #

/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define CIN(s) int (s);cin>>(s);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    VV dp(n+1,V(k+1));
    VV vec(n,V(m));
    rep(i,n)rep(j,m){
         cin>>vec[i][j];
    }
    dp[0][0]=1;
    rep(i,n){
        rep(j,k+1){
            rep(l,m){
                //dp[i+1][j]=dp[i][j];
                if(vec[i][l]+j<=k){
                    dp[i+1][vec[i][l]+j]+=dp[i][j];
                }
            }
        }
    }
  //  cout<<dp[n][1]<<endl;
    for(int i=k;i>=0;i--){
        if(dp[n][i]!=0){
            cout<<k-i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}
0