# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
436340 | iulia13 | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 351 ms | 16836 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 = 2e6 + 6;
#define ll long long
map <ll, ll> cate;
map <ll, ll> dp;
set <ll> s;
ll v[N];
ll a[N], b[N];
int main()
{
ll n, m, nr, i, h, j, na, nb;
cin >> n >> m;
for (i = 0; i < n; i++)
cin >> v[i];
h = n / 2;
for (i = 0; i < (1 << h); i++)
{
for (j = 0; j < h; j++)
if (i & (1 << j))
a[i] += v[j];
}
na = (1 << h);
sort(a, a + na);
for (i = h; i < n; i++)
v[i - h] = v[i];
h = n - h;
for (i = 0; i < (1 << h); i++)
{
for (j = 0; j < h; j++)
if (i & (1 << j))
b[i] += v[j];
}
nb = (1 << h);
sort(b, b + nb);
na--;
nb--;
j = nb;
ll ans = 0;
for (i = 0; i <= na; i++)
{
while (b[j] + a[i] > m && j > -1)
j--;
ans += (j + 1);
}
cout << ans;
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... |