結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 11 ms
4,380 KB
testcase_07 AC 11 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 11 ms
4,376 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<long long> a;
map<vector<int>,int> mp;
vector<int> v;

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

int main() {
  cin >> n >> w;
  a = vector<long long>(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