結果

問題 No.1701 half price
ユーザー SSRS
提出日時 2021-10-08 21:52:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 1,533 ms
コンパイル使用メモリ 169,196 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-23 03:56:45
合計ジャッジ時間 2,347 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 10 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int dfs(int N, int W, vector<int> &a, int p, long long S){
  if (p == N){
    if (S == W){
      return 1;
    } else {
      return 0;
    }
  } else {
    int ans = 0;
    ans += dfs(N, W, a, p + 1, S);
    ans += dfs(N, W, a, p + 1, S + a[p] / 2);
    ans += dfs(N, W, a, p + 1, S + a[p]);
    return ans;
  }
}
int main(){
  int N, W;
  cin >> N >> W;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  cout << dfs(N, W, a, 0, 0) << endl;
}
0