結果

問題 No.393 2本の竹
ユーザー ふーらくたるふーらくたる
提出日時 2016-07-28 03:19:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,591 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 62,872 KB
実行使用メモリ 30,876 KB
最終ジャッジ日時 2024-04-24 10:27:16
合計ジャッジ時間 2,530 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 26 ms
30,684 KB
testcase_03 AC 32 ms
30,756 KB
testcase_04 AC 32 ms
30,632 KB
testcase_05 AC 38 ms
30,720 KB
testcase_06 AC 30 ms
30,584 KB
testcase_07 AC 29 ms
30,628 KB
testcase_08 AC 59 ms
30,736 KB
testcase_09 AC 94 ms
30,820 KB
testcase_10 WA -
testcase_11 AC 48 ms
30,720 KB
testcase_12 AC 47 ms
30,828 KB
testcase_13 AC 42 ms
30,848 KB
testcase_14 AC 38 ms
30,848 KB
testcase_15 AC 16 ms
30,644 KB
testcase_16 WA -
testcase_17 AC 36 ms
30,576 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 53 ms
30,644 KB
testcase_23 WA -
testcase_24 AC 33 ms
30,720 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 59 ms
30,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

#define REP(i, x) for (int i = 0; i < (x); i++)
#define REPE(i, x) for (int i = 0; i <= (x); i++)
#define RREP(i, x) for (int i = (x) - 1; i >= 0; i--)
#define RREPE(i, x) for (int i = (x); i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORE(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define RFORE(i, a, b) for (int i = (a); i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()

typedef pair<int, int> PII;

const int kMaxN = 100010;
const int kMaxM = 70;

int dp[kMaxM][kMaxN];
int A[kMaxM];

int main() {
    int d;
    cin >> d;

    while (d--) {
        int n1, n2, m;
        cin >> n1 >> n2;

        cin >> m;
        REP (i, m) {
            cin >> A[i];
        }

        sort(A, A + m);

        memset(dp, 0, sizeof(dp));

        int ans = 0, should_use = 0;
        FORE (b_num, 1, m) {
            REPE(use, n1) {
                int other_use = should_use - use;
                if (other_use < 0) continue;

                if (use - A[b_num - 1] >= 0) {
                    dp[b_num][use] = max(dp[b_num][use], dp[b_num - 1][use - A[b_num - 1]] + 1);
                }
                if (other_use + A[b_num - 1] <= n2) {
                    dp[b_num][use] = max(dp[b_num][use], dp[b_num - 1][use] + 1);
                }
                ans = max(ans, dp[b_num][use]);
            }
            should_use += A[b_num - 1];
        }
        cout << ans << endl;
    }
    return 0;
}
0