結果

問題 No.1701 half price
ユーザー Nzt3Nzt3
提出日時 2022-09-29 17:02:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 544 bytes
コンパイル時間 2,422 ms
コンパイル使用メモリ 200,844 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 04:59:21
合計ジャッジ時間 3,743 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 7 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 65 ms
4,380 KB
testcase_07 AC 64 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 64 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long N,W;
  cin>>N>>W;
  vector<long long>A(N);
  for(auto &i:A)cin>>i;
  int ans=0;
  for(int i=0;i<1<<N;i++){
    vector<long long>B;
    for(int j=0;j<N;j++){
      if(i>>j&1)B.push_back(A[j]);
    }
    int t=0;
    for(int j=0;j<1<<B.size();j++){
      long long s=0;
      for(int k=0;k<B.size();k++){
        if(j>>k&1)s+=B[k]/2;
        else s+=B[k];
      }
      if(s==W)t=1;
    }
    ans+=t;
  }
  cout<<ans<<'\n';
}
0