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;
#define endl "\n"
typedef long long int ll;
vector<int> v1,v2,v;
set<ll>d1,d2;
void solve(int idx,ll s,int t){
if(t==1) {
if(idx==(int)v1.size()) {
d1.insert(s);
return;
}
}
else{
if(idx==(int)v2.size()) {
d2.insert(s);
return;
}
}
solve(idx+1,s+v1[idx],t);
solve(idx+1,s,t);
}
set<ll> an;
ll n,m;
ll ans=0;
void solv(int idx,ll s){
if(idx==n) {
if(s<=m) {
ans++;
}
return;
}
solv(idx+1,s+v[idx]);
solv(idx+1,s);
}
int main()
{
ios_base:: sync_with_stdio(false); cin.tie(0);
cin>>n>>m;
for(int i=1; i<=n; i++) {
int a; cin>>a;
v.push_back(a);
// if(i&1) v1.push_back(a);
//else v2.push_back(a);
}
//solve(0,0,1);
//solve(0,0,2);
solv(0,0);
// for(int u:an) cout<<u<<" ";
//cout<<endl;
cout<<ans<<endl;
/*
for(int v:d1) {
cout<<v<<endl;
// auto it=d2.lower_bound(m-v);
//ans+=(distance(d2.begin(),it));
}
cout<<"set 2"<<endl;
for(int v:d2) {
cout<<v<<endl;
// auto it=d2.lower_bound(m-v);
//ans+=(distance(d2.begin(),it));
}
*/
//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... |