# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
462012 | kingfran1907 | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 484 ms | 8636 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>
#define X first
#define Y second
using namespace std;
typedef long long llint;
const int maxn = 2e5+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 18;
const int off = 1 << logo;
const int treesiz = off << 1;
int n;
llint m;
llint niz[maxn];
vector< llint > v;
int main() {
scanf("%d%lld", &n, &m);
for (int i = 0; i < n; i++)
scanf("%lld", niz+i);
int hf = n / 2;
int lim = (1 << hf);
for (int mask = 0; mask < lim; mask++) {
llint sum = 0;
for (int i = 0; i < hf; i++)
if (mask & (1 << i)) sum += niz[i];
v.push_back(sum);
}
sort(v.begin(), v.end());
llint sol = 0;
lim = (1 << (n - hf));
for (int mask = 0; mask < lim; mask++) {
llint sum = 0;
for (int i = 0; i < n - hf; i++) {
if (mask & (1 << i)) sum += niz[i];
}
int ind = upper_bound(v.begin(), v.end(), m - sum) - v.begin();
sol += ind;
}
printf("%lld\n", sol);
return 0;
}
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... |