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;
typedef long long LL;
const LL MOD=1000000007;
map<LL,LL> byk;
LL a[25],b[25];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
LL n,m,ans=0;
cin >> n >> m;
LL first=n/2,second=n-first;
for(LL i=0;i<first;i++)cin >> a[i];
for(LL i=0;i<second;i++)cin >> b[i];
for(LL i=0;i<(1<<first);i++){
LL brp=0;
for(LL j=0;j<first;j++){
if(i & (1<<j))brp+=a[j];
}
byk[brp]++;
}
for(auto it=byk.begin();it!=byk.end();++it){
if(it==byk.begin())continue;
auto prev=it;
--prev;
byk[it->first]+=byk[prev->first];
}
for(LL i=0;i<(1<<second);i++){
LL brp=0;
for(LL j=0;j<second;j++){
if(i & (1<<j))brp+=b[j];
}
//butuh maksimal m-brp
auto butuh=byk.upper_bound(m-brp);
if(butuh==byk.begin())continue;
--butuh;
ans+=(butuh->second);
}
cout << ans << endl;
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... |