This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define vvi vector<vector<int>>
#define ld long double
#define ar array
#define pb push_back
#define vi vector<int>
#define vc vector
#define vpi vector<pair<int, int>>
#define pii pair<int, int>
#define all(c) (c).begin(), (c).end()
#define endll '\n'
#define fastio ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
#define lb(a, x) lower_bound(all(a), x) - a.begin();
#define ub(a, x) upper_bound(all(a), x) - a.begin();
template<typename T> bool umax(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool umin(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
mt19937 rng(time(0));
const int sz = 5e5 + 5;
void solve() {
int n, m;
cin >> n >> m;
int a[n];
for(int i = 0; i < n; ++i){
cin >> a[i];
}
int res = 0;
for(int mask = 0; mask < (1 << n); mask++){
int s = 0;
for(int i = 0; i < n; ++i){
if(1 << i & mask){
s += a[i];
}
}
res += s <= m;
}
cout << res << endl;
}
signed main() {
fastio
int T = 1;
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... |