結果

問題 No.1457 ツブ消ししとるなHard
ユーザー shiomusubi496shiomusubi496
提出日時 2021-03-26 11:21:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 784 bytes
コンパイル時間 2,178 ms
コンパイル使用メモリ 176,136 KB
実行使用メモリ 49,828 KB
最終ジャッジ日時 2023-08-19 14:49:46
合計ジャッジ時間 2,784 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 27 ms
29,248 KB
testcase_05 AC 28 ms
32,704 KB
testcase_06 AC 24 ms
28,908 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 4 ms
6,820 KB
testcase_10 AC 3 ms
5,392 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 8 ms
11,304 KB
testcase_13 AC 3 ms
5,424 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 5 ms
8,248 KB
testcase_16 AC 43 ms
49,828 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 15 ms
19,224 KB
testcase_20 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int N,M,X,Y,Z;
    cin>>N>>M>>X>>Y>>Z;
    int cnt=0;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(A[i]>=X)cnt++;
    }
    if(cnt>M){
        puts("Handicapped");
        return 0;
    }
    vector<vector<vector<ll>>>dp(N+1,vector<vector<ll>>(M+1,vector<ll>(M*Z+1)));
    dp[0][0][0]=1;
    for(int i=0;i<N;i++){
        if(A[i]<X){
            dp[i+1]=dp[i];
        }
        if(A[i]>Y){
            for(int j=0;j<M;j++){
                for(int k=0;k+A[i]<=M*Z;k++){
                    dp[i+1][j+1][k+A[i]]+=dp[i][j][k];
                }
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=M;i++){
        ans+=dp[N][i][i*Z];
    }
    cout<<ans<<endl;
}
0