結果
問題 | No.1701 half price |
ユーザー |
|
提出日時 | 2021-10-08 23:25:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 83 ms / 3,000 ms |
コード長 | 827 bytes |
コンパイル時間 | 1,347 ms |
コンパイル使用メモリ | 113,520 KB |
最終ジャッジ日時 | 2025-01-24 23:25:25 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <set> #include <map> #include <queue> #include <cmath> #include <iomanip> using namespace std; typedef long long ll; #define rep(i, n) for (int i=0;i < (int)(n);i++) int n; set<ll> st; map<ll,int> mp; vector<ll> a; void dfs(int bit,ll w,int d){ if (d == n){ st.insert(w); return; } if (bit & 1 << d) { dfs(bit,w+a[d],d+1); dfs(bit,w+a[d]/2,d+1); } else{ dfs(bit,w,d+1); } } int main(){ ll w; cin >> n >> w; a.resize(n); rep(i,n) cin >> a[i]; for (int bit = 1; bit < (1 << n);bit++){ st.clear(); dfs(bit,0,0); for (auto q:st){ mp[q]++; } } cout << mp[w] << endl; return 0; }