結果
問題 | No.914 Omiyage |
ユーザー |
|
提出日時 | 2019-10-25 21:26:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 497 bytes |
コンパイル時間 | 1,527 ms |
コンパイル使用メモリ | 172,420 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 16:22:51 |
合計ジャッジ時間 | 2,215 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int N, M, K; cin >> N >> M >> K; vector<vector<int>> A(N, vector<int>(M)); for(int i=0; i<N; i++) for(int j=0; j<M; j++) cin >> A[i][j]; bool ok[11][501] = {0}; ok[0][K] = true; for(int i=0; i<N; i++) for(int a : A[i]) for(int j=a; j<=K; j++) if(ok[i][j]) ok[i+1][j-a] = true; for(int j=0; j<=K; j++) if(ok[N][j]){ cout << j << endl; return 0; } cout << -1 << endl; return 0; }