結果

問題 No.1457 ツブ消ししとるなHard
ユーザー sushitorunasushitoruna
提出日時 2021-03-19 14:44:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 1,734 ms
コンパイル使用メモリ 168,100 KB
実行使用メモリ 52,404 KB
最終ジャッジ日時 2023-08-19 14:49:23
合計ジャッジ時間 2,754 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,608 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
5,540 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 17 ms
52,404 KB
testcase_05 AC 15 ms
50,456 KB
testcase_06 AC 23 ms
29,676 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 4 ms
13,660 KB
testcase_10 AC 3 ms
13,844 KB
testcase_11 AC 4 ms
9,588 KB
testcase_12 AC 9 ms
36,236 KB
testcase_13 AC 4 ms
21,904 KB
testcase_14 AC 4 ms
21,900 KB
testcase_15 AC 5 ms
21,892 KB
testcase_16 AC 3 ms
9,780 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 1 ms
4,384 KB
testcase_19 AC 18 ms
52,208 KB
testcase_20 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;using ll=long long;
#define rep(i,r) for(ll i=0;i<(r);i++)
#define Rep(i,l,r) for(ll i=(l);i<(r);i++)
ll dp[51][51][2501];
int main()
{
    ll n,m,x,y,z,cnt=0,sum=0;
    cin>>n>>m>>x>>y>>z;
    vector<ll>v;
    rep(i,n)
    {
        ll a;
        cin>>a;
        if(a>=x)cnt++,sum+=a;
        else if(a>y)v.push_back(a);
    }
    if(cnt>m)
    {
        cout<<"Handicapped"<<endl;return 0;
    }
    n=v.size();
    dp[0][0][0]=1;
    Rep(i,1,n+1)rep(j,i+1)rep(k,2501)
    {
        if(k>=v[i-1]&&j>0)
            dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-v[i-1]];
        else
            dp[i][j][k]=dp[i-1][j][k];
    }
    ll ans=0;
    Rep(i,1,m-cnt+1)
        if(z*(i+cnt)>=sum)ans+=dp[n][i][z*(i+cnt)-sum];
    cout<<ans<<endl;
}
0