This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(), v.end()
#define pb push_back
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
int main()
{
ll n, m, i, j, ans = 0, sum = 0;
cin >> n >> m;
vl v(n);
for(i = 0; i < n; i++)
cin >> v[i];
for(i = 1; i < (1 << n); i++)
{
sum = 0;
for(j = 0; j < n; j++)
{
if((i >> j) & 1)
sum += v[j];
}
if(sum <= m)
ans++;
}
cout << ans + 1 << "\n";
}
# | 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... |