結果
| 問題 | No.393 2本の竹 |
| コンテスト | |
| ユーザー |
togari_takamoto
|
| 提出日時 | 2016-07-12 07:09:02 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 160 ms / 1,000 ms |
| コード長 | 865 bytes |
| 記録 | |
| コンパイル時間 | 1,218 ms |
| コンパイル使用メモリ | 189,540 KB |
| 実行使用メモリ | 46,148 KB |
| 最終ジャッジ日時 | 2026-05-08 11:59:43 |
| 合計ジャッジ時間 | 3,048 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 |
ソースコード
#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 ALL(c) (c).begin(), (c).end()
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
ll d; cin >> d;
REP(_, d) {
ll n1, n2, m; cin >> n1 >> n2 >> m;
vl a(m); REP(i, m) cin >> a[i];
sort(ALL(a));
vvl dp(m + 1, vl(n1 + 1, n2 + 1));
dp[0][0] = 0; // dp[i人までで][n1のうちk利用するときの] = n2の利用した最小の長さ
FOR(i, 1, m + 1) REP(k, n1 + 1) {
if(k - a[i - 1] >= 0) dp[i][k] = min(dp[i][k], dp[i - 1][k - a[i - 1]]);
dp[i][k] = min(dp[i][k], dp[i - 1][k] + a[i - 1]);
}
ll ans = 0;
REP(i, m + 1) REP(j, n1 + 1) if (dp[i][j] <= n2) ans = max(ans, i);
cout << ans << endl;
}
return 0;
}
togari_takamoto