結果

問題 No.1861 Required Number
ユーザー MtSakaMtSaka
提出日時 2021-12-27 03:02:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 205,572 KB
実行使用メモリ 33,012 KB
最終ジャッジ日時 2023-09-26 02:58:55
合計ジャッジ時間 15,118 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
33,012 KB
testcase_01 AC 2 ms
8,752 KB
testcase_02 AC 2 ms
8,756 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 11 ms
4,376 KB
testcase_25 AC 24 ms
5,456 KB
testcase_26 AC 7 ms
4,376 KB
testcase_27 AC 12 ms
5,100 KB
testcase_28 AC 12 ms
4,960 KB
testcase_29 AC 10 ms
5,264 KB
testcase_30 AC 7 ms
5,372 KB
testcase_31 AC 24 ms
5,536 KB
testcase_32 AC 7 ms
5,520 KB
testcase_33 AC 18 ms
5,476 KB
testcase_34 AC 21 ms
5,416 KB
testcase_35 AC 21 ms
5,408 KB
testcase_36 AC 11 ms
5,524 KB
testcase_37 AC 14 ms
5,276 KB
testcase_38 AC 22 ms
5,340 KB
testcase_39 AC 14 ms
5,500 KB
testcase_40 AC 25 ms
5,728 KB
testcase_41 AC 23 ms
5,416 KB
testcase_42 AC 21 ms
5,804 KB
testcase_43 AC 14 ms
5,268 KB
testcase_44 AC 2 ms
4,376 KB
04_evil_1.txt TLE -
04_evil_2.txt TLE -
04_evil_3.txt WA -
04_evil_4.txt TLE -
権限があれば一括ダウンロードができます

ソースコード

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<bitset<1000>>dpl(N+1),dpr(N+2);
  dpl[0][0]=dpr[N+1][0]=1;
  for(int i=0;i<N;i++){
    dpl[i+1]=dpl[i]|(dpl[i]<<A[i]);
  }
  for(int i=N-1;i>=0;i--){
    dpr[i+1]=dpr[i+2]|(dpr[i+2]<<A[i]);
  }
  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