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;
long long a,b,c,d,e,f[49],i,j,zx,xc,pas;
map <long long, long long> m;
map <long long, long long>::iterator t;
set <pair <long long, long long> > s;
set <pair <long long, long long> >::iterator it;
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a>>b;
for(c=0; c<a; c++) cin>>f[c];
d=min(20LL,a);
for(c=0; c<(1<<d); c++){
e=0;
for(i=0; i<d; i++){
if(((1<<i)&c)!=0) e+=f[i];
}
m[e]++;
}
e=0;
for(t=m.begin(); t!=m.end(); t++){
e+=(*t).second;
s.insert(make_pair((*t).first,e));
}
if(a<=20){
it=s.lower_bound(make_pair(b+1,0));
if(it==s.begin()){
cout<<0;
}else{
it--;
cout<<(*it).second;
}
return 0;
}
e=a-d;
for(c=0; c<(1<<e); c++){
zx=c*(1<<d);
xc=0;
for(i=d; i<a; i++){
if(((1<<i)&c)!=0) xc+=f[i];
}
it=s.lower_bound(make_pair(b+1-xc,0));
if(it==s.begin()){
}else{
it--;
pas+=(*it).second;
}
}
cout<<pas;
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... |