結果
問題 | No.914 Omiyage |
ユーザー |
![]() |
提出日時 | 2020-06-28 19:32:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 893 bytes |
コンパイル時間 | 1,036 ms |
コンパイル使用メモリ | 103,808 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-08 01:18:58 |
合計ジャッジ時間 | 2,335 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
// I SELL YOU...! #include<iostream> #include<vector> #include<algorithm> #include<functional> #include<queue> #include<chrono> #include<iomanip> #include<map> #include<set> using namespace std; using ll = long long; using P = pair<ll,ll>; using TP = tuple<ll,ll,ll>; void init_io(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } signed main(){ init_io(); ll n,m,k; cin >> n >> m >> k; vector<vector<ll>> a(n,vector<ll>(m)); vector<vector<bool>> dp(n+1,vector<bool>(k+1,false)); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cin >> a[i][j]; } } dp[0][0] = true; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ for(int x=a[i][j];x<=k;x++){ dp[i+1][x] = dp[i+1][x]|dp[i][x-a[i][j]]; } } } ll ans = k+1; for(int i=0;i<=k;i++){ if(dp[n][i]){ ans = i; } } cout << k-ans << endl; }