# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
148083 | WhipppedCream | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 547 ms | 8784 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>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;
int n;
ll S;
const int maxn = 45;
ll arr[maxn];
vector< ll > half;
ll ways;
int main()
{
scanf("%d %lld", &n, &S);
for(int i = 1; i<= n; i++) scanf("%lld", &arr[i]);
int m = n/2;
for(int bit = 0; bit< (1<<m); bit++)
{
ll loc = 0;
for(int i = 0; i< m; i++)
{
if((1<<i) & bit) loc += arr[i+1];
}
half.pb(loc);
}
sort(half.begin(), half.end());
m = n-n/2;
for(int bit = 0; bit< (1<<m); bit++)
{
ll loc = 0;
for(int i = 0; i< m; i++)
{
if((1<<i)&bit) loc += arr[n/2+1+i];
}
ways += upper_bound(half.begin(), half.end(), S-loc)-half.begin();
}
printf("%lld\n", ways);
}
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... |