結果

問題 No.1701 half price
ユーザー Nzt3
提出日時 2022-09-29 17:03:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 66 ms / 3,000 ms
コード長 544 bytes
コンパイル時間 1,898 ms
コンパイル使用メモリ 196,728 KB
最終ジャッジ日時 2025-02-07 18:20:24
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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=1;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