結果

問題 No.393 2本の竹
ユーザー pekempeypekempey
提出日時 2016-07-12 00:37:12
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 783 bytes
コンパイル時間 1,271 ms
コンパイル使用メモリ 150,820 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-07 14:13:52
合計ジャッジ時間 3,282 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,380 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 13 ms
4,376 KB
testcase_03 AC 9 ms
4,376 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 13 ms
4,376 KB
testcase_08 AC 31 ms
4,376 KB
testcase_09 AC 103 ms
4,380 KB
testcase_10 AC 24 ms
4,376 KB
testcase_11 AC 36 ms
4,380 KB
testcase_12 AC 35 ms
4,376 KB
testcase_13 AC 34 ms
4,380 KB
testcase_14 AC 22 ms
4,376 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 8 ms
4,376 KB
testcase_22 AC 37 ms
4,376 KB
testcase_23 AC 58 ms
4,380 KB
testcase_24 AC 7 ms
4,380 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 78 ms
4,376 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 <= 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