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 <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
#include <complex>
using u32 = unsigned;
using i32 = int;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using namespace std;
using pt = complex<f80>;
#define ALL(x) begin(x), end(x)
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
#define N 400005
#define A 21
int n;
u64 z, a, b[44];
vector<u64> v;
int main()
{
ShinLena;
cin >> n >> a;
for (int i = 0; i < n; ++i) cin >> b[i];
for (int i = 1; i < (1 << min(A, n)); ++i)
{
u64 z = 0;
for (int j = 0; j < min(A, n); ++j)
if ((i >> j) & 1) z += b[j];
if (z > a) continue;
++::z;
v.emplace_back(z);
}
sort(ALL(v));
if (n >= A)
{
for (int i = 1; i < (1 << (n - A)); ++i)
{
u64 z = {};
for (int j = A; j < n; ++j)
if ((i >> (j - A)) & 1) z += b[j];
if (z > a) continue;
{
++::z;
auto it = upper_bound(ALL(v), a - z);
::z += it - begin(v);
}
}
}
cout << z + 1;
return 0;
}
# | 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... |