#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define ll long long
#define int long long
const long long inf=1e18;
const int MOD=1e9+7;
const int N=41;
int a[N],n,m,ans=0;
bool flag=0;
vector<int> v;
void func(int i,int score){
if(flag && i==n/2){
auto it=upper_bound(v.begin(),v.end(),m-score)-v.begin();
ans+=it;
return;
}
if(i==n){
v.pb(score);
return;
}
func(i+1,score);
if(score+a[i]<=m)func(i+1,score+a[i]);
}
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>m;
for(int i=0;i<n;i++)cin>>a[i];
func(n/2,0);
flag=1;
sort(v.begin(),v.end());
func(0,0);
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
388 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
1500 KB |
Output is correct |
2 |
Correct |
50 ms |
2520 KB |
Output is correct |
3 |
Correct |
255 ms |
10192 KB |
Output is correct |
4 |
Correct |
52 ms |
2516 KB |
Output is correct |
5 |
Correct |
4 ms |
992 KB |
Output is correct |
6 |
Correct |
3 ms |
736 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
1500 KB |
Output is correct |
2 |
Correct |
16 ms |
1500 KB |
Output is correct |
3 |
Correct |
110 ms |
5844 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
736 KB |
Output is correct |
6 |
Correct |
6 ms |
992 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
2520 KB |
Output is correct |
2 |
Correct |
75 ms |
6096 KB |
Output is correct |
3 |
Correct |
78 ms |
6100 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
25 ms |
5588 KB |
Output is correct |
6 |
Correct |
83 ms |
8988 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
180 ms |
9680 KB |
Output is correct |
2 |
Correct |
15 ms |
1496 KB |
Output is correct |
3 |
Correct |
5 ms |
736 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
860 KB |
Output is correct |
6 |
Correct |
89 ms |
8652 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
1500 KB |
Output is correct |
2 |
Correct |
54 ms |
2516 KB |
Output is correct |
3 |
Correct |
4 ms |
732 KB |
Output is correct |
4 |
Correct |
4 ms |
736 KB |
Output is correct |
5 |
Correct |
28 ms |
4564 KB |
Output is correct |
6 |
Correct |
11 ms |
1500 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
193 ms |
8652 KB |
Output is correct |
2 |
Correct |
17 ms |
1500 KB |
Output is correct |
3 |
Correct |
5 ms |
736 KB |
Output is correct |
4 |
Correct |
244 ms |
9936 KB |
Output is correct |
5 |
Correct |
34 ms |
4564 KB |
Output is correct |
6 |
Correct |
6 ms |
992 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |