結果

問題 No.393 2本の竹
ユーザー pekempeypekempey
提出日時 2016-08-20 16:48:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 94 ms / 1,000 ms
コード長 795 bytes
コンパイル時間 1,208 ms
コンパイル使用メモリ 164,404 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 21:29:13
合計ジャッジ時間 2,571 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,812 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 13 ms
6,940 KB
testcase_03 AC 9 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 5 ms
6,944 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 13 ms
6,944 KB
testcase_08 AC 29 ms
6,940 KB
testcase_09 AC 94 ms
6,940 KB
testcase_10 AC 25 ms
6,944 KB
testcase_11 AC 37 ms
6,940 KB
testcase_12 AC 35 ms
6,944 KB
testcase_13 AC 35 ms
6,940 KB
testcase_14 AC 25 ms
6,940 KB
testcase_15 AC 31 ms
6,940 KB
testcase_16 AC 42 ms
6,940 KB
testcase_17 AC 9 ms
6,940 KB
testcase_18 AC 4 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 3 ms
6,944 KB
testcase_21 AC 8 ms
6,940 KB
testcase_22 AC 38 ms
6,944 KB
testcase_23 AC 45 ms
6,944 KB
testcase_24 AC 7 ms
6,940 KB
testcase_25 AC 5 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 72 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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();
}
0