結果
問題 | No.914 Omiyage |
ユーザー |
![]() |
提出日時 | 2019-10-25 21:45:40 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,026 bytes |
コンパイル時間 | 1,406 ms |
コンパイル使用メモリ | 159,352 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 16:27:23 |
合計ジャッジ時間 | 1,892 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;using P=pair<int,int>;const int MOD=1e9+7;const int INF=1<<30;const int MAX=1e5;template<class T>inline void xmin(T &a, T b){a=(a<b)?a:b;}template<class T>inline void xmax(T &a, T b){a=(a>b)?a:b;}int n;int m,k;int a[11][11];int dp[11][501];void solve(){cin>>n>>m>>k;for(int i=0; i<n; i++){for(int j=0; j<m; j++){cin>>a[i][j];}}for(int i=0; i<m; i++){dp[1][a[0][i]]=1;}for(int i=1; i<n; i++){for(int j=0; j<m; j++){for(int ii=0; ii<501; ii++){if(ii+a[i][j]<=k && dp[i][ii]==1){dp[i+1][ii+a[i][j]]=1;}}}}int cnt=0;int ans=0;while(cnt!=k+1){if(dp[n][cnt]){ans=cnt;}cnt++;}if(dp[n][ans]==0){cout<<-1<<endl;return;}cout<<k-ans<<endl;}signed main(){//while(1)solve();}