結果

問題 No.1457 ツブ消ししとるなHard
ユーザー boutarouboutarou
提出日時 2021-03-31 23:04:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,451 bytes
コンパイル時間 2,411 ms
コンパイル使用メモリ 201,448 KB
実行使用メモリ 71,940 KB
最終ジャッジ日時 2023-08-22 04:02:00
合計ジャッジ時間 3,284 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,632 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
5,596 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 7 ms
20,104 KB
testcase_10 AC 7 ms
20,196 KB
testcase_11 AC 5 ms
13,932 KB
testcase_12 AC 20 ms
49,052 KB
testcase_13 AC 11 ms
28,488 KB
testcase_14 AC 7 ms
28,036 KB
testcase_15 AC 11 ms
30,544 KB
testcase_16 AC 9 ms
14,328 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < int(n); i++)
using ll = long long;
using P = pair<int, int>;

int zero = 3000;
// dp[i][j][k] = 品物iまで見てj個購入して総和がk(-zero)の通り数
int dp[55][55][6300];

// 6 3 6 2 4
// 2 2 3 5 1 1

// 2 -2
// newa = {x-2, x-2, -1, 1, x-3, x-3}


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n, m, x, y, z;
    cin >> n >> m >> x >> y >> z;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    x -= z, y -= z;
    rep(i, n) a[i] -= z;
    int sum = 0, cnt = 0;
    vector<int> think;
    rep(i, n) {
        if (a[i] >= x) {
            sum += a[i];
            cnt++;
        }
        else if (a[i] > y) {
            think.push_back(a[i]);
        }
    }
    if(cnt > m) {
        cout << "Handicapped" << endl;
        return 0;
    }
    dp[0][0][sum + zero] = 1;
    rep(i, think.size()) {
        rep(j, m - cnt + 1) {
            rep(k, zero * 2) {
                dp[i + 1][j][k] += dp[i][j][k];
                if(j != m - cnt && 0 <= k + think[i] && k + think[i] < zero * 2) {
                    dp[i + 1][j + 1][k + think[i]] += dp[i][j][k];
                }
            }
        } 
    }
    int ans = 0;
    rep(i, m - cnt + 1) {
        if (i == 0) {
            if(cnt != 0) ans += dp[think.size()][i][zero];
        }
        else ans += dp[think.size()][i][zero];
    }
    cout << ans << endl;
}
0