結果

問題 No.1457 ツブ消ししとるなHard
ユーザー SotaUN
提出日時 2021-03-31 22:45:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,798 bytes
コンパイル時間 1,885 ms
コンパイル使用メモリ 171,624 KB
実行使用メモリ 54,040 KB
最終ジャッジ日時 2024-12-15 20:56:52
合計ジャッジ時間 3,382 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    //cout << -2 << endl;
    ll n,m,x,y,z;
    cin >> n >> m >> x >> y >> z;
    ll wa = 0;
    ll ka = 0;
    vector<ll> a;
    for(int i = 0;i < n;i++){
        ll in;
        cin >> in;
        if(in >= x)wa += in,ka++;
        else if(in > y){
            a.push_back(in);
        }
    }
    if(ka > m){
        cout << "Handicapped" << endl;
        return 0;
    }
    //cout << 1 << endl;
    //cout << a.size() << endl;
    ll dp[51][51][2501];//i番目まででjつ選んで合計がkの時の通り数
    for(int i = 0;i < 50;i++)for(int j = 0;j < 51;j++)for(int k = 0;k < 2501;k++)dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    for(int i = 0;i < a.size();i++){
        //cout << a[i] << " ";
        if(i == 0)dp[i][1][a[i]] = 1;
        else{
            for(int j = 0;j < 2501;j++){
                for(int k = 0;k <= 50;k++){
                    dp[i][k][j] = dp[i - 1][k][j];
                    if(j - a[i] < 0 || k == 0)continue;
                    dp[i][k][j] += dp[i - 1][k - 1][j - a[i]];
                    //if(i == 2 && k == 1 && j == 4)cout << "!!!!!" << a[i] << " " << dp[i - 1][k - 1][j - a[i]] << endl;
                }
            }
        }
    }
    //cout << "% " << dp[0][0][0] << " " << dp[1][0][0] << " " << dp[2][0][0] << endl;
    //cout << endl;
    //cout << dp[1][2][8] << endl;
    //cout << ka << " " << wa << endl;
    ll res = 0;
    for(int i = 0;i < 51;i++){
        for(int j = 0;j < 2501;j++){
            if(i + ka <= 0)continue;
            if((i + ka) * z == wa + j){
                //cout << "!" << " " << i << " " << j << " " << dp[a.size() - 1][i][j] << endl;
                res += dp[a.size() - 1][i][j];
            }
        }
    }
    cout << res << endl;
}
0