結果
問題 | No.393 2本の竹 |
ユーザー |
|
提出日時 | 2016-08-20 16:48:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 103 ms / 1,000 ms |
コード長 | 795 bytes |
コンパイル時間 | 1,435 ms |
コンパイル使用メモリ | 163,556 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 09:27:47 |
合計ジャッジ時間 | 3,021 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include <bits/stdc++.h>using namespace std;template<class T1, class T2> bool chmin(T1 &a, T2 b) { if (b < a) { a = b; return true; } return false; }template<class T1, class T2> bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true; } return false; }void solve() {int n1, n2;cin >> n1 >> n2;int m;cin >> m;vector<int> a(m);for (int i = 0; i < m; i++) cin >> a[i];sort(a.begin(), a.end());int ans = 0;for (int i = 0; i <= m; i++) {bitset<100100> dp;dp[0] = 1;int sum = 0;for (int j = 0; j < i; j++) {sum += a[j];dp |= dp << a[j];}for (int j = 0; j <= min(100000, sum); j++) {int k = sum - j;if (dp[j] && j <= n1 && k <= n2) {ans = i;}}}cout << ans << endl;}int main() {int d;cin >> d;while (d--) solve();}