結果

問題 No.1701 half price
ユーザー mmn15277198mmn15277198
提出日時 2021-10-09 07:59:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 839 bytes
コンパイル時間 1,094 ms
コンパイル使用メモリ 107,092 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-01 01:35:14
合計ジャッジ時間 2,217 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 11 ms
4,380 KB
testcase_07 AC 11 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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;
  }
  dfs(sum , id + 1);
  v.push_back(id);
  dfs(sum + a[id] , id + 1);
  dfs(sum + a[id] / 2 , id + 1);
  v.pop_back();
  return;
}

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