結果

問題 No.1701 half price
ユーザー 👑 CleyL
提出日時 2023-03-28 15:35:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 517 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 72,520 KB
最終ジャッジ日時 2025-02-11 18:51:06
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
  long long n,w;cin>>n>>w;
  vector<long long> A(n);
  for(int i = 0; n > i; i++)cin>>A[i];
  long long ans = 0;
  for(int j = 0; (1<<n) > j; j++){
    for(int i = 0; (1<<n) > i; i++){
      long long tmp = 0;
      for(int k = 0; n > k; k++){
        if(j & (1<<k)){
          if(i & (1<<k))tmp += A[k]/2;
          else tmp += A[k];
        }
      }
      if(tmp == w){
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}
0