結果

問題 No.393 2本の竹
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2016-07-13 14:49:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 849 bytes
コンパイル時間 1,744 ms
コンパイル使用メモリ 168,044 KB
実行使用メモリ 26,840 KB
最終ジャッジ日時 2024-04-23 01:52:41
合計ジャッジ時間 3,600 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
22,108 KB
testcase_01 AC 3 ms
7,888 KB
testcase_02 AC 6 ms
24,140 KB
testcase_03 AC 4 ms
13,920 KB
testcase_04 AC 3 ms
11,996 KB
testcase_05 AC 4 ms
9,816 KB
testcase_06 AC 3 ms
9,808 KB
testcase_07 AC 4 ms
14,068 KB
testcase_08 AC 6 ms
20,200 KB
testcase_09 RE -
testcase_10 AC 17 ms
11,492 KB
testcase_11 AC 23 ms
14,836 KB
testcase_12 AC 28 ms
18,532 KB
testcase_13 AC 20 ms
18,144 KB
testcase_14 AC 13 ms
16,180 KB
testcase_15 RE -
testcase_16 AC 20 ms
25,652 KB
testcase_17 AC 5 ms
18,152 KB
testcase_18 AC 4 ms
14,036 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 3 ms
9,936 KB
testcase_21 AC 6 ms
20,176 KB
testcase_22 AC 34 ms
15,504 KB
testcase_23 AC 16 ms
13,436 KB
testcase_24 AC 4 ms
11,900 KB
testcase_25 AC 3 ms
7,788 KB
testcase_26 AC 2 ms
7,764 KB
testcase_27 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)


int d;
int n1, n2, m;
int A[61];
//-----------------------------------------------------------------
int dp[60][101010];

void solve() {
	scanf("%d %d %d", &n1, &n2, &m);
	rep(i, 0, m) scanf("%d", &A[i]);
	sort(A, A + m);

	rep(i, 0, m + 1) rep(j, 0, n1 + 1) dp[i][j] = -1;
	dp[0][n1] = 0;

	int sum = 0;
	int ans = 0;
	rep(i, 0, m) {
		
		rep(j, 0, n1 + 1) if (0 <= dp[i][j]) {
			ans = max(ans, dp[i][j]);

			int jj = n2 - (sum - (n1 - j));

			if (A[i] <= j) dp[i + 1][j - A[i]] = dp[i][j] + 1;
			if (A[i] <= jj) dp[i + 1][j] = dp[i][j] + 1;
		}
		sum += A[i];
	}
	rep(i, 0, n1 + 1) ans = max(ans, dp[m][i]);

	cout << ans << endl;
}
//-----------------------------------------------------------------
int main() {
	scanf("%d", &d);
	rep(i, 0, d) solve();
}
0