結果
| 問題 |
No.914 Omiyage
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2019-10-25 21:49:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 789 bytes |
| コンパイル時間 | 548 ms |
| コンパイル使用メモリ | 71,880 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 16:27:27 |
| 合計ジャッジ時間 | 1,160 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
bool dp[11][501];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int N, M, K;
int A[10][10];
cin >> N >> M >> K;
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 k = 0; k <= K; k++){
if(dp[i][k] && k+A[i][j] <= K) dp[i+1][k+A[i][j]] = true;
}
}
}
int ans = -1;
for(int i = 0; i <= K; i++){
if(dp[N][i]) ans = K-i;
}
cout << ans << endl;
}
milanis48663220