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>
#define int long long
using namespace std;
vector<int> Q;
int t[2000000];
int32_t main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++)
cin>>t[i];
for(int i=0;i<(1<<(n/2));i++)
{
int pom=i;
int gdzie=0;
int suma=0;
while(pom>0)
{
if(pom%2==1)
suma+=t[gdzie];
pom/=2;
gdzie++;
}
Q.push_back(suma);
}
sort(Q.begin(),Q.end());
int wynik=0;
for(int i=0;i<(1<<((n+1)/2));i++)
{
int pom=i;
int gdzie=0;
int suma=0;
while(pom>0)
{
if(pom%2==1)
suma+=t[gdzie+n/2];
pom/=2;
gdzie++;
}
gdzie=upper_bound(Q.begin(),Q.end(),m-suma)-Q.begin();
gdzie--;
if(gdzie>=0)
wynik+=gdzie+1;
}
cout<<wynik;
return 0;
}
# | 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... |