結果

問題 No.1861 Required Number
ユーザー MtSakaMtSaka
提出日時 2021-12-27 02:51:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 843 bytes
コンパイル時間 2,310 ms
コンパイル使用メモリ 207,036 KB
実行使用メモリ 6,900 KB
最終ジャッジ日時 2023-09-26 02:55:29
合計ジャッジ時間 8,951 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 52 ms
6,588 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
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;
    int main(){
      int N,K;
      cin>>N>>K;
      vector<int>A(N);
      for(int i=0;i<N;i++)cin>>A[i];
      vector<vector<bool>>dpl(N+1,vector<bool>(K+1,false)),dpr(N+2,vector<bool>(K+1,false));
      dpl[0][0]=dpr[N+1][0]=true;
      for(int i=0;i<N;i++){
        for(int j=0;j<=K-A[i];j++){
          if(dpl[i][j])dpl[i+1][j+A[i]]=true;
        }
      }
      for(int i=N-1;i>=0;i--){
        for(int j=0;j<=K-A[i];j++){
          if(dpr[i+2][j])dpr[i+1][j+A[i]]=true;
        }
      }
      if(!dpl[N][K]){
        cout<<-1<<endl;
        return 0;
      }
      int ans=0;
      for(int i=1;i<=N;i++){
        bool flag=true;
        for(int j=0;j<=K;j++){
          if(dpl[i-1][j]&&dpr[i+1][K-j])flag=false;
        }
        if(flag)ans++;
      }
      cout<<ans<<endl;
    }
0