結果

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>

using namespace std;

int n;
long long w;
vector<int> a;
map<vector<int>,int> mp;
long long ans = 0;
vector<int> v;

void dfs(long long sum , int id) {
  //cout << id << " " << sum << endl;
  if (id >= n) {
    if (sum == w) {
      vector<int> v2 = v;
      sort(v2.begin() , v2.end());
      mp[v2]++;
    }
    return;
  }
  v.push_back(id);
  dfs(sum + a[id] , id + 1);
  dfs(sum + a[id] / 2 , id + 1);
  v.pop_back();
  dfs(sum , id + 1);
  return;
}

int main() {
  cin >> n >> w;
  a = vector<int>(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dfs(0,0);
  cout << mp.size() << endl;
  return 0;
}
0