#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
// using namespace chrono;
// using namespace atcoder;
// template <typename T>
// using ordered_set =
// tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define rep(i, a, b) for(int i = a;i<b;i++)
#define ss second
#define ff first
template<typename T>
auto operator<<(ostream &os, T&v)->decltype(v.begin(), os){
os << "[";
int f = 0;
for(auto i:v) {
if(f++)os << ", ";
os << i;
}
os << "]";
return os;
}
template<typename F, typename S>
auto& operator<<(ostream &os, pair<F, S> const &p) {
return os << "(" << p.first << ", " << p.second << ")";
}
void debug(){}
template<typename T, typename... V>
void debug(T t, V... v) {
cerr << t;
if(sizeof...(v)) {
cerr << ", "; debug(v...);
}
}
#ifdef LOCAL
#define dbg(x...) cerr << "[" << #x << "]: " << "["; debug(x); cerr << "]\n";
#define nl cerr << "\n";
#else
#define dbg(x...)
#define nl
#endif
vector<vector<long long> > g(80, vector<long long> (80, 0));
long long dp[80][80];
void solve() {
int n;
long long k;
cin >> n >> k;
long long sz1 = (n+1)>>1, sz2 = n - ((n+1)>>1);
long long a[sz1], b[sz2];
for(int i=0;i<n;i++) {
if(i < sz1)cin >> a[i];
else cin >> b[i-sz1];
}
vector<long long> suma;
for(long long i = 0;i<(1ll<<sz1);i++) {
long long s = 0;
for(int j = 0;j<sz1;j++) {
if(i&(1ll<<j))s += a[j];
}
suma.push_back(s);
}
long long ans = 0;
sort(suma.begin(), suma.end());
dbg(suma);
for(long long i = 0;i<(1ll<<sz2);i++) {
long long s = 0;
for(int j = 0;j<sz1;j++) {
if(i&(1ll<<j))s += b[j];
}
dbg(s, k-s);
ans += (--upper_bound(suma.begin(), suma.end(), k-s)) - suma.begin();
}
cout << ans << endl;
}
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while(t--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
1476 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
39 ms |
1476 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
63 ms |
2684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
287 ms |
8716 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
1504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
367 ms |
8720 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |