#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
int n;
cin>>n;
ll k;
cin>>k;
vector<ll>v;
int p=n/2;
int p1=n-p;
vector<ll>vc;
for(int i=0;i<n;i++)
{
ll a;
cin>>a;
v.push_back(a);
}
ll res=0;
for(int i=1;i<(1<<p);i++)
{
ll s=0;
for(int j=0;j<p;j++)
{
if(i&(1<<j))
{
s+=v[j];
}
}
if(s<=k)
{
vc.push_back(s);
res++;
}
}
sort(vc.begin(),vc.end());
for(int i=1;i<(1<<p1);i++)
{
ll s=0;
for(int j=0;j<p1;j++)
{
if(i&(1<<j))
{
s+=v[j+p];
}
}
if(s<=k)
{
res++;
res+=(upper_bound(vc.begin(),vc.end(),k-s)-vc.begin());
}
}
res++;
cout<<res<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
292 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
288 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
924 KB |
Output is correct |
2 |
Correct |
106 ms |
2392 KB |
Output is correct |
3 |
Correct |
468 ms |
8624 KB |
Output is correct |
4 |
Correct |
102 ms |
2464 KB |
Output is correct |
5 |
Correct |
16 ms |
840 KB |
Output is correct |
6 |
Correct |
8 ms |
688 KB |
Output is correct |
7 |
Correct |
8 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
1436 KB |
Output is correct |
2 |
Correct |
36 ms |
840 KB |
Output is correct |
3 |
Correct |
207 ms |
4516 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
8 ms |
692 KB |
Output is correct |
6 |
Correct |
15 ms |
948 KB |
Output is correct |
7 |
Correct |
8 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
1416 KB |
Output is correct |
2 |
Correct |
175 ms |
2472 KB |
Output is correct |
3 |
Correct |
167 ms |
2464 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
97 ms |
2472 KB |
Output is correct |
6 |
Correct |
250 ms |
8624 KB |
Output is correct |
7 |
Correct |
51 ms |
324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
374 ms |
4516 KB |
Output is correct |
2 |
Correct |
31 ms |
840 KB |
Output is correct |
3 |
Correct |
10 ms |
688 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
8 ms |
588 KB |
Output is correct |
6 |
Correct |
207 ms |
4520 KB |
Output is correct |
7 |
Correct |
8 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
924 KB |
Output is correct |
2 |
Correct |
100 ms |
2468 KB |
Output is correct |
3 |
Correct |
9 ms |
588 KB |
Output is correct |
4 |
Correct |
10 ms |
588 KB |
Output is correct |
5 |
Correct |
122 ms |
2496 KB |
Output is correct |
6 |
Correct |
21 ms |
928 KB |
Output is correct |
7 |
Correct |
133 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
411 ms |
8660 KB |
Output is correct |
2 |
Correct |
36 ms |
924 KB |
Output is correct |
3 |
Correct |
11 ms |
712 KB |
Output is correct |
4 |
Correct |
485 ms |
8548 KB |
Output is correct |
5 |
Correct |
137 ms |
4432 KB |
Output is correct |
6 |
Correct |
15 ms |
952 KB |
Output is correct |
7 |
Correct |
16 ms |
292 KB |
Output is correct |