結果
問題 | No.914 Omiyage |
ユーザー |
![]() |
提出日時 | 2019-10-25 21:31:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 684 bytes |
コンパイル時間 | 591 ms |
コンパイル使用メモリ | 74,152 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-24 16:24:10 |
合計ジャッジ時間 | 1,191 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <algorithm>#include <cstring>#include <cstdlib>#include <cmath>using namespace std;using ll = long long;int main() {int n, m, k;cin >> n >> m >> k;int p[11][501] = {};p[0][0] = 1;for (int i = 0; i < n; i++) {for (int j = 0; j < m; j++) {int a;cin >> a;for (int k = a; k <= 500; k++) {p[i + 1][k] |= p[i][k - a];}}}for (int k1 = k; k1 >= 0; k1--) {if (p[n][k1]) {cout << k - k1 << endl;exit(0);}}cout << -1 << endl;return 0;}