# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
972723 | blackslex | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 312 ms | 22844 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;
using ll = long long;
int n;
ll m;
int main() {
scanf("%d %lld", &n, &m);
vector<ll> a(n);
for (auto &e: a) scanf("%lld", &e);
auto get = [&] (int l, int r) {
vector<ll> c;
int sz = r - l + 1;
for (int i = 0; i < (1 << sz); i++) {
ll csum = 0;
for (int j = 0; j < sz; j++) {
if (i & (1 << j)) csum += a[j + l];
}
c.emplace_back(csum);
}
sort(c.begin(), c.end());
return c;
};
int posl = 0, posr = n / 2;
auto cl = get(posl, posr - 1), cr = get(posr, n - 1);
ll ans = (lower_bound(cr.begin(), cr.end(), m) - cr.begin()) + (lower_bound(cl.begin(), cl.end(), m) - cl.begin()) - 1;
for (auto &e: cl) {
auto lower = lower_bound(cr.begin(), cr.end(), m - e);
if (*lower > e) lower = prev(lower);
ans += (lower - cr.begin());
}
printf("%lld", ans);
}
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... |