#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define ll long long
#define ull unsigned long long
#define lb lower_bound
#define ub upper_bound
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
int gcd(int a, int b){
return __gcd(a, b);
}
int lcm(int a, int b){
return a / gcd(a, b) * b;
}
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
void solve(){
int n, m, ans = 0;
cin >> n >> m;
vector<int> vt;
for (int i = 1; i <= n; i++ ){
int a;
cin >> a;
vt.push_back(a);
}
for (int mask = 0; mask < (1 << n); mask++){
int x = 0;
for (int i = 0; i < n; i++){
if((mask & (1 << i)) > 0)x += vt[i];
}
if(x <= m)ans++;
}
cout << ans << endl;
}
signed main(){
IOS;
int t = 1;
//cin >> t;
while (t--){
solve();
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |