結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 7 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 7 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 64 ms
4,376 KB
testcase_07 AC 64 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 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 AC 20 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 65 ms
4,376 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=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