結果

問題 No.1457 ツブ消ししとるなHard
ユーザー hiro71687khiro71687k
提出日時 2023-08-26 23:35:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 1,501 bytes
コンパイル時間 4,209 ms
コンパイル使用メモリ 265,028 KB
実行使用メモリ 66,568 KB
最終ジャッジ日時 2023-08-26 23:36:06
合計ジャッジ時間 5,755 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,004 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 3 ms
4,816 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 60 ms
66,496 KB
testcase_05 AC 55 ms
61,632 KB
testcase_06 AC 60 ms
66,568 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 15 ms
20,288 KB
testcase_10 AC 15 ms
20,300 KB
testcase_11 AC 4 ms
6,452 KB
testcase_12 AC 53 ms
66,560 KB
testcase_13 AC 16 ms
20,184 KB
testcase_14 AC 15 ms
20,232 KB
testcase_15 AC 31 ms
40,540 KB
testcase_16 AC 48 ms
66,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 58 ms
66,560 KB
testcase_20 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=998244353;
ll inf=1009999999999999990;
int main(){
    ll n,m,x,y,z;
    cin >> n >> m >> x >> y >> z;
    vector<ll>a(n);
    vector<ll>b;
    ll now=0;
    ll ko=0;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i]>=x)
        {
            now+=a[i];
            ko++;
        }else{
            if (a[i]<=y)
            {
                continue;
            }
            b.push_back(a[i]);
        }
    }
    if (ko>m)
    {
        cout << "Handicapped" << endl;
        return 0;
    }
    ll nn=b.size();
    if (nn==0)
    {
        if (ko*z==now)
        {
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
        return 0;
    }
    vector<vector<vector<ll>>>dp(n,vector<vector<ll>>(n+3,vector<ll>(3000,0)));
    dp[0][ko][now]=1;
    dp[0][ko+1][b[0]+now]=1;
    for (ll i = 1; i < nn; i++)
    {
        for (ll j = 0; j <= m; j++)
        {
            for (ll k = 0; k < 2900; k++)
            {
                dp[i][j][k]+=dp[i-1][j][k];
                dp[i][j+1][k+b[i]]+=dp[i-1][j][k];
            }
        }
    }
    ll ans=0;
    for (ll i = 1; i <=m; i++)
    {
        for (ll j = 0; j <=2500; j++)
        {
            if (i*z==j)
            {
                ans+=dp[nn-1][i][j];
            }
        }
    }
    cout << ans << endl;
}
0