結果

問題 No.393 2本の竹
ユーザー h_nosonh_noson
提出日時 2016-07-15 11:09:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 30 ms / 1,000 ms
コード長 1,005 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 68,420 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 21:28:23
合計ジャッジ時間 1,419 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 30 ms
6,940 KB
testcase_10 AC 9 ms
6,940 KB
testcase_11 AC 12 ms
6,940 KB
testcase_12 AC 14 ms
6,940 KB
testcase_13 AC 9 ms
6,944 KB
testcase_14 AC 6 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 6 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 1 ms
6,944 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 18 ms
6,940 KB
testcase_23 AC 8 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 26 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP (i,0,(int)(n)-1)
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP (i,(int)(n)-1,0)

const int INF = 1e8;
const int MOD = 1e9+7;

typedef long long ll;

int dp[100001];

int main(void) {
    int d;
    int a[60];
    cin >> d;
    while (d--) {
        int i, j, k, m;
        int n[2];
        cin >> n[0] >> n[1] >> m;
        rep (i,m) cin >> a[i];
        sort(a,a+m);
        rep (i,n[0]+1) dp[i] = 0;
        int sum = 0;
        rep (i,m) {
            rrep(j,n[0]+1) if (dp[j] == i) {
                if (sum >= j && n[1] - (sum - j) >= a[i])
                    dp[j] = i+1;
                if (n[0] - j >= a[i])
                    dp[j+a[i]] = i+1;
            }
            sum += a[i];
        }
        int ans = 0;
        rep (i,n[0]+1) ans = max(ans,dp[i]);
        cout << ans << endl;
    }
    return 0;
}
0