# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
975258 | duckindog | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 238 ms | 22496 KiB |
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>
using namespace std;
const int N = 40 + 10;
int n;
long long m;
long long a[N], b[N];
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m;
vector<long long> first = {0}, second = {0};
{
int x = (n + 1 >> 1), y = n - x;
for (int i = 1; i <= x; ++i) cin >> a[i];
for (int i = 1; i <= y; ++i) cin >> b[i];
for (int bit = 1; bit < (1 << x); ++bit) {
long long sum = 0;
for (int j = 1; j <= x; ++j) sum += (bit >> j - 1 & 1) * a[j];
if (sum <= m) first.push_back(sum);
}
for (int bit = 1; bit < (1 << y); ++bit) {
long long sum = 0;
for (int j = 1; j <= y; ++j) sum += (bit >> j - 1 & 1) * b[j];
if (sum <= m) second.push_back(sum);
}
}
sort(first.begin(), first.end());
sort(second.begin(), second.end());
long long answer = 0;
for (const auto& x : first) answer += upper_bound(second.begin(), second.end(), m - x) - second.begin();
cout << answer << "\n";
}
Compilation message (stderr)
# | 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... |