結果

問題 No.1861 Required Number
ユーザー kaichou243kaichou243
提出日時 2022-03-05 01:12:20
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 999 bytes
コンパイル時間 2,384 ms
コンパイル使用メモリ 207,652 KB
実行使用メモリ 6,968 KB
最終ジャッジ日時 2023-09-26 04:50:51
合計ジャッジ時間 11,212 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 119 ms
6,968 KB
testcase_04 AC 120 ms
6,708 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 37 ms
4,376 KB
testcase_25 AC 91 ms
6,132 KB
testcase_26 AC 19 ms
4,376 KB
testcase_27 AC 36 ms
4,988 KB
testcase_28 AC 41 ms
4,636 KB
testcase_29 AC 26 ms
4,744 KB
testcase_30 AC 10 ms
4,504 KB
testcase_31 AC 95 ms
6,272 KB
testcase_32 AC 13 ms
4,452 KB
testcase_33 AC 65 ms
5,452 KB
testcase_34 AC 76 ms
5,956 KB
testcase_35 AC 78 ms
6,000 KB
testcase_36 AC 27 ms
4,656 KB
testcase_37 AC 40 ms
5,076 KB
testcase_38 AC 80 ms
5,720 KB
testcase_39 AC 47 ms
4,896 KB
testcase_40 AC 95 ms
6,512 KB
testcase_41 AC 89 ms
6,128 KB
testcase_42 AC 72 ms
5,644 KB
testcase_43 AC 42 ms
5,120 KB
testcase_44 AC 1 ms
4,376 KB
04_evil_1.txt MLE -
04_evil_2.txt MLE -
04_evil_3.txt MLE -
04_evil_4.txt MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<vector<bool>> dpl(n+1,vector<bool>(k+1)),dpr(n+1,vector<bool>(k+1));
    dpl[0][0]=true;
    dpr[0][0]=true;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(a[i-1]<=j){
                dpl[i][j]=(dpl[i][j]|dpl[i-1][j-a[i-1]]);
            }
            dpl[i][j]=(dpl[i][j]|dpl[i-1][j]);
        }
    }
    reverse(a.begin(),a.end());
    for(int i=1;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(a[i-1]<=j){
                dpr[i][j]=(dpr[i][j]|dpr[i-1][j-a[i-1]]);
            }
            dpr[i][j]=(dpr[i][j]|dpr[i-1][j]);
        }
    }
    ll cnt=0;
    for(int i=1;i<=n;i++){
        bool this_is=false;
        for(int j=0;j<=k;j++){
            if(dpl[i-1][j]&&dpr[n-i][k-j]) this_is=true;
        }
        if(!this_is){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}
0