#include <bits//stdc++.h>
using namespace std;
const int mod=1e9+7;
int n;
long long m,a[50];
vector <long long> v1,v2;
void bt (int pos,int x,long long sum)
{
if (pos==x)
{
if (x==n)
v2.push_back(sum);
else
v1.push_back(sum);
return;
}
bt(pos+1,x,sum);
bt(pos+1,x,sum+a[pos]);
}
int main()
{
cin >>n>>m;
for (int i=0;i<n;i++)
cin >>a[i];
v2.push_back(m+1);
bt(0,n/2,0);
bt(n/2,n,0);
sort(v2.begin(),v2.end());
long long ans=0;
for (int i=0;i<v1.size();i++)
{
long long x=(m-v1[i]);
ans+= ((upper_bound(v2.begin(),v2.end(),x)-v2.begin()));
ans%=mod;
}
cout <<ans;
return 0;
}
Compilation message
bobek.cpp: In function 'int main()':
bobek.cpp:30:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<v1.size();i++)
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
352 KB |
Output is correct |
2 |
Correct |
2 ms |
424 KB |
Output is correct |
3 |
Correct |
1 ms |
568 KB |
Output is correct |
4 |
Correct |
1 ms |
568 KB |
Output is correct |
5 |
Correct |
1 ms |
568 KB |
Output is correct |
6 |
Correct |
1 ms |
568 KB |
Output is correct |
7 |
Correct |
1 ms |
568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
588 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
588 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
620 KB |
Output is correct |
7 |
Correct |
1 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
620 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Correct |
2 ms |
620 KB |
Output is correct |
4 |
Correct |
1 ms |
620 KB |
Output is correct |
5 |
Correct |
1 ms |
620 KB |
Output is correct |
6 |
Correct |
1 ms |
620 KB |
Output is correct |
7 |
Correct |
1 ms |
620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
3292 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
41 ms |
3800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
64 ms |
5844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
279 ms |
21188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
31 ms |
21188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
354 ms |
25268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |