# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
46929 | alex99 | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 371 ms | 17568 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 <iostream>
#include <algorithm>
using namespace std;
int N;
long long M;
long long A[(1 << 21) + 5], B[(1<< 21) + 5];
long long C[45];
void Read()
{
cin >> N >> M;
for(int i = 1; i <= N; i++)
{
cin >> C[i];
}
}
void precalcAB()
{
int lim = N / 2;
for(int conf = 0; conf < (1 << lim); conf++)
{
long long sum = 0;
for(int j = 0; j < lim; j++)
{
if((conf & (1 << j)) != 0)
sum += C[j + 1];
}
A[conf] = sum;
}
for(int conf = 0; conf < (1 << (N - lim)); conf++)
{
long long sum = 0;
for(int j = 0; j < N - lim; j++)
{
if((conf & (1 << j)) != 0)
sum += C[j + lim + 1];
}
B[conf] = sum;
}
int x = (1 << lim);
int y = ((1 << (N - lim)));
sort(A, A + (1 << lim));
sort(B , B + (1 << (N - lim)));
int point = 0, point2 = y - 1;
long long ans = 0;
for(int i = 0; i < x; i++)
{
while(point2 >= 0 && B[point2] + A[i] > M)
--point2;
ans += point2 + 1;
}
cout << ans << '\n';
}
int main()
{
Read();
precalcAB();
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... |