結果

問題 No.1457 ツブ消ししとるなHard
ユーザー sushitorunasushitoruna
提出日時 2021-03-19 13:51:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 780 bytes
コンパイル時間 1,886 ms
コンパイル使用メモリ 168,144 KB
実行使用メモリ 52,396 KB
最終ジャッジ日時 2023-08-19 14:49:01
合計ジャッジ時間 2,318 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,488 KB
testcase_01 AC 2 ms
4,356 KB
testcase_02 WA -
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,376 KB
testcase_09 AC 4 ms
13,692 KB
testcase_10 AC 3 ms
13,616 KB
testcase_11 AC 2 ms
9,512 KB
testcase_12 AC 10 ms
36,256 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 5 ms
21,812 KB
testcase_16 AC 2 ms
9,536 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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,m-cnt+1)
        if(z*(i+cnt)>=sum)ans+=dp[n][i][z*(i+cnt)-sum];
    cout<<ans<<endl;
}
0