# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
972728 | blackslex | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 368 ms | 22836 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];
}
if (csum <= m) 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 = cl.size() + cr.size() - 1;
for (auto &e: cl) {
if (!e) continue;
auto upper = upper_bound(cr.begin(), cr.end(), m - e); upper = prev(upper);
ans += (upper - 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... |