結果

問題 No.393 2本の竹
ユーザー togari_takamototogari_takamoto
提出日時 2016-07-12 06:59:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,061 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 174,148 KB
実行使用メモリ 818,940 KB
最終ジャッジ日時 2023-08-05 03:17:16
合計ジャッジ時間 5,194 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
21,064 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 9 ms
6,876 KB
testcase_03 AC 18 ms
9,612 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 7 ms
6,024 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 32 ms
10,952 KB
testcase_08 AC 95 ms
20,160 KB
testcase_09 MLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)

int main() {
	cin.tie(0); // cinとcoutの連携を切る
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll d; cin >> d;
	REP(_, d) {
		ll n1, n2, m; cin >> n1 >> n2 >> m;
		vl a(m); REP(i, m) cin >> a[i];
		vector<vvl> dp(m + 1, vvl(m + 1, vl(n1 + 1, TEN(9))));
		dp[0][0][0] = 0; // dp[i人までで][j人が満足し][n1のうちk利用するときの] = n2の利用した最小の長さ
		FOR(i, 1, m + 1) REP(j, m + 1) REP(k, n1 + 1) {
			if(j > 0) dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - 1][k] + a[i - 1]);
			if(j > 0 && k - a[i - 1] >= 0) dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - 1][k - a[i - 1]]);
			dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k]);
		}

		ll ans = 0;
		REP(i, m + 1) REP(j, n1 + 1) if (dp[m][i][j] <= n2) ans = max(ans, i);
		cout << ans << endl;
	}
	return 0;
}
0