結果

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

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
ll A[12][12];
ll dp[12][510];
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll N, M, K;
cin >> N >> M >> K;
REP(i, N){
REP(j, M){
cin >> A[i][j];
}
}
REP(i, N+1){
REP(j, 510){
dp[i][j] = 0;
}
}
dp[0][0] = 1;
REP(i, N){
REP(j, 510){
if(dp[i][j] == 0) continue;
REP(k, M){
if(j+A[i][k]<510) dp[i+1][j+A[i][k]] = 1;
}
}
}
ll ma = -1;
REP(i, K+1){
if(dp[N][i]) ma = max(ma, (ll)i);
}
cout << (ma==-1 ? ma : K-ma) << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0