結果

問題 No.1457 ツブ消ししとるなHard
ユーザー MZKiMZKi
提出日時 2021-03-31 22:15:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,555 bytes
コンパイル時間 1,416 ms
コンパイル使用メモリ 154,512 KB
実行使用メモリ 55,056 KB
最終ジャッジ日時 2023-08-22 02:25:56
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 54 ms
54,964 KB
testcase_05 AC 50 ms
51,060 KB
testcase_06 AC 54 ms
55,000 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 5 ms
6,560 KB
testcase_10 AC 5 ms
6,740 KB
testcase_11 AC 3 ms
4,852 KB
testcase_12 AC 27 ms
27,664 KB
testcase_13 AC 9 ms
11,224 KB
testcase_14 AC 9 ms
11,180 KB
testcase_15 AC 11 ms
11,984 KB
testcase_16 AC 3 ms
5,148 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 54 ms
55,056 KB
testcase_20 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define eps (double)(1e-9)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, m, x, y, z;
    cin >> n >> m >> x >> y >> z;
    vector<ll> a(n), v;
    rep(i, n)cin >> a[i];
    ll sum = 0, cnt = 0;
    rep(i, n){
        if(a[i] >= x){
            m--;
            cnt++;
            sum += a[i];
        }
        if(a[i] < x && a[i] > y)v.push_back(a[i]);
    }
    if(m <= 0){
        cout << "Handicapped" << endl;
        return 0;
    }
    n = v.size();
    a = v;
    vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(n+1, vector<ll>(2501, 0)));
    dp[0][0][0] = 1;
    rep(i, n){
        rep(j, n+1){
            rep(k, 2501){
                if(j != n && k+a[i] <= 2500)dp[i+1][j+1][k+a[i]] += dp[i][j][k];
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    rep(i, n+1){
        if(i > m)continue;
        if(cnt+i == 0)continue;
        int k = z*(cnt+i)-sum;
        if(0 <= k && k <= 2500)ans += dp[n][i][k];
    }
    cout << ans << endl;
}
0