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>
//#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define ARRS ((ll)(2e6+500))
#define MAX ((ll)(1e6+100))
#define MOD ((ll)1e6+7)
#define mi(a,b) a=min((a),(b))
ll n,m,k,p,l,r,q;
ll a[ARRS];
ll b[ARRS];
ll s[ARRS];
ll es[ARRS];
int main(){
#ifdef KHOKHO
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
ios::sync_with_stdio(0);
ll S;
cin>>n>>S;
ll m=n/2;
n=n-m;
for(int i=0; i<n; i++)cin>>a[i];
for(int i=0; i<m; i++)cin>>b[i];
for(int i=0; i<(1<<n); i++)
for(int t=0; t<n; t++)
if((i>>t)&1)s[i]+=a[t];
for(int i=0; i<(1<<m); i++)
for(int t=0; t<m; t++)
if((i>>t)&1)es[i]+=b[t];
sort(s,s+(1<<n));
sort(es,es+(1<<m));
ll pas=0;
for(int i=0; i<(1<<n); i++){
pas+=upper_bound(es,es+(1<<m),S-s[i])-es;
}
cout<<pas;
}
# | 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... |