#include<bits/stdc++.h>
using namespace std;
long long int n,m,i,j,a[42],mid,sum,ans;
vector <long long int> v;
int main()
{
cin>>n>>m;
for(i=0;i<n;i++)
{
cin>>a[i];
}
mid=n/2+1;
for(i=0;i<(1<<mid);i++)
{
for(j=0;j<mid;j++)
{
if((i>>j)&1)
{
sum+=a[j];
}
}
v.push_back(sum);
sum=0;
}
int fn=mid;
mid=n-mid;
sort(v.begin(),v.end());
for(i=0;i<(1<<mid);i++)
{
for(j=0;j<mid;j++)
{
if((i>>j)&1)
{
sum+=a[j+fn];
}
}
if(sum>m)continue;
ans+=upper_bound(v.begin(),v.end(),m-sum)-v.begin();
sum=0;
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
508 KB |
Output is correct |
2 |
Correct |
2 ms |
556 KB |
Output is correct |
3 |
Correct |
2 ms |
556 KB |
Output is correct |
4 |
Correct |
2 ms |
556 KB |
Output is correct |
5 |
Correct |
2 ms |
556 KB |
Output is correct |
6 |
Correct |
2 ms |
556 KB |
Output is correct |
7 |
Correct |
2 ms |
556 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
556 KB |
Output is correct |
2 |
Incorrect |
2 ms |
680 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
680 KB |
Output is correct |
2 |
Incorrect |
2 ms |
680 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
59 ms |
1764 KB |
Output is correct |
2 |
Correct |
151 ms |
4824 KB |
Output is correct |
3 |
Correct |
624 ms |
17220 KB |
Output is correct |
4 |
Correct |
142 ms |
17220 KB |
Output is correct |
5 |
Incorrect |
23 ms |
17220 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
17220 KB |
Output is correct |
2 |
Correct |
42 ms |
17220 KB |
Output is correct |
3 |
Correct |
265 ms |
17220 KB |
Output is correct |
4 |
Correct |
2 ms |
17220 KB |
Output is correct |
5 |
Correct |
11 ms |
17220 KB |
Output is correct |
6 |
Correct |
27 ms |
17220 KB |
Output is correct |
7 |
Incorrect |
25 ms |
17220 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
72 ms |
17220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
392 ms |
17220 KB |
Output is correct |
2 |
Correct |
36 ms |
17220 KB |
Output is correct |
3 |
Correct |
16 ms |
17220 KB |
Output is correct |
4 |
Incorrect |
2 ms |
17220 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
17220 KB |
Output is correct |
2 |
Correct |
129 ms |
17220 KB |
Output is correct |
3 |
Correct |
15 ms |
17220 KB |
Output is correct |
4 |
Incorrect |
17 ms |
17220 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
555 ms |
17220 KB |
Output is correct |
2 |
Correct |
40 ms |
17220 KB |
Output is correct |
3 |
Correct |
19 ms |
17220 KB |
Output is correct |
4 |
Incorrect |
619 ms |
17220 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |