#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n, sz;
long long m, x;
cin >> n >> m;
vector < long long > a, b;
for(int i = 0; i < n; i++){
cin >> x;
if(i & 1){
a.push_back(x);
}
else{
b.push_back(x);
}
}
long long ans = 0;
sz = (int)a.size();
vector < long long > q;
for(int i = 1; i < (1 << sz); i++){
long long sum = 0;
for(int j = 0; j < sz; j++){
if((i >> j) & 1){
sum += a[j];
}
}
if(sum <= m){
ans += 1;
q.push_back(sum);
}
}
sort(q.begin(), q.end());
sz = (int)b.size();
for(int i = 1; i < (1 << sz); i++){
long long sum = 0;
for(int j = 0; j < sz; j++){
if((i >> j) & 1){
sum += b[j];
}
}
if(sum <= m){
ans += 1;
ans += upper_bound(q.begin(), q.end(), m - sum) - q.begin();
}
}
cout << ans + 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
316 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
1024 KB |
Output is correct |
2 |
Correct |
101 ms |
2552 KB |
Output is correct |
3 |
Correct |
635 ms |
8788 KB |
Output is correct |
4 |
Correct |
112 ms |
2544 KB |
Output is correct |
5 |
Correct |
18 ms |
1024 KB |
Output is correct |
6 |
Correct |
11 ms |
768 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
1532 KB |
Output is correct |
2 |
Correct |
34 ms |
1024 KB |
Output is correct |
3 |
Correct |
210 ms |
4668 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
10 ms |
768 KB |
Output is correct |
6 |
Correct |
18 ms |
1024 KB |
Output is correct |
7 |
Correct |
10 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
1532 KB |
Output is correct |
2 |
Correct |
174 ms |
2552 KB |
Output is correct |
3 |
Correct |
189 ms |
2552 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
93 ms |
2552 KB |
Output is correct |
6 |
Correct |
280 ms |
8672 KB |
Output is correct |
7 |
Correct |
48 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
418 ms |
4556 KB |
Output is correct |
2 |
Correct |
31 ms |
1024 KB |
Output is correct |
3 |
Correct |
14 ms |
768 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
10 ms |
768 KB |
Output is correct |
6 |
Correct |
197 ms |
4596 KB |
Output is correct |
7 |
Correct |
12 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1024 KB |
Output is correct |
2 |
Correct |
104 ms |
2552 KB |
Output is correct |
3 |
Correct |
12 ms |
640 KB |
Output is correct |
4 |
Correct |
11 ms |
768 KB |
Output is correct |
5 |
Correct |
123 ms |
2552 KB |
Output is correct |
6 |
Correct |
24 ms |
1024 KB |
Output is correct |
7 |
Correct |
131 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
506 ms |
8788 KB |
Output is correct |
2 |
Correct |
40 ms |
1024 KB |
Output is correct |
3 |
Correct |
13 ms |
768 KB |
Output is correct |
4 |
Correct |
588 ms |
8668 KB |
Output is correct |
5 |
Correct |
134 ms |
4588 KB |
Output is correct |
6 |
Correct |
19 ms |
1024 KB |
Output is correct |
7 |
Correct |
19 ms |
384 KB |
Output is correct |