# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
159217 | Akashi | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 409 ms | 20920 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;
int n, l;
long long m;
long long a[42];
vector <long long> v[2];
void back(int i, int n, long long Sum = 0){
if(Sum > m) return ;
if(i == n + 1){
v[l].push_back(Sum);
return ;
}
back(i + 1, n, Sum);
back(i + 1, n, Sum + a[i]);
}
int main()
{
scanf("%d%lld", &n, &m);
for(int i = 1; i <= n ; ++i)
scanf("%lld", &a[i]);
l = 0;
back(1, n / 2);
l = 1;
back(n / 2 + 1, n);
sort(v[1].begin(), v[1].end());
long long Sol = 0;
for(auto it : v[0]){
int pos = upper_bound(v[1].begin(), v[1].end(), m - it) - v[1].begin();
Sol = Sol + pos;
}
printf("%lld", Sol);
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... |