結果
問題 | No.914 Omiyage |
ユーザー |
![]() |
提出日時 | 2019-10-25 21:27:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 836 bytes |
コンパイル時間 | 1,685 ms |
コンパイル使用メモリ | 171,264 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 16:22:25 |
合計ジャッジ時間 | 2,549 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define int long long#define REP(i,n) for(int i = 0;i < (int)(n);i++)#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)#define FOR(i,s,n) for(int i = s;i < (int)n;i++)#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)#define ALL(a) a.begin(),a.end()template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}constexpr long long INF = 1e18;signed main(){int N,M,K;cin>>N>>M>>K;vector<int>dp(K+1,0);dp[0]=1;REP(i,N){vector<int>ndp(K+1,0);REP(j,M){int t;cin>>t;REP(k,K+1){if(k+t>K)continue;ndp[k+t]|=dp[k];}}dp=ndp;}int ans = -1;REP(i,K+1)if(dp[i])CHMAX(ans,i);if(ans==-1)cout<<-1<<endl;else cout<<K-ans<<endl;}