#include<bits/stdc++.h>
using namespace std;
const long long maxn = 40;
const long long maxc = (1 << 20) + 10;
long long A, B;
long long n, m;
long long a[maxn];
long long b[maxn];
long long a2[maxc];
long long b2[maxc];
long long ans;
void in();
void solve();
void out();
int main(){
in();
solve();
out();
}
void in(){
ios::sync_with_stdio(false);
cin >> n >> m;
for(long long i = 0; i < n / 2; i++)
cin >> a[i + 1];
A = n / 2;
for(long long i = n / 2; i < n; i++)
cin >> b[i - n / 2 + 1];
B = n - A;
}
void solve(){
for(long long i = 1; i < (1 << A); i++){
a2[i] = a2[i - (i & -i)];
a2[i] += a[__builtin_ctz(i) + 1];
}
for(long long i = 1; i < (1 << B); i++){
b2[i] = b2[i - (i & -i)];
b2[i] += b[__builtin_ctz(i) + 1];
}
sort(a2, a2 + (1 << A));
sort(b2, b2 + (1 << B));
A = 1 << A;
B = 1 << B;
long long nowb = B - 1;
for(long long i = 0; i < A; i++){
while(nowb != -1 && b2[nowb] + a2[i] > m)
nowb--;
ans += nowb + 1;
}
}
void out(){
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
380 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
408 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1916 KB |
Output is correct |
2 |
Correct |
54 ms |
4472 KB |
Output is correct |
3 |
Correct |
220 ms |
16760 KB |
Output is correct |
4 |
Correct |
54 ms |
4472 KB |
Output is correct |
5 |
Correct |
10 ms |
1400 KB |
Output is correct |
6 |
Correct |
10 ms |
1016 KB |
Output is correct |
7 |
Correct |
15 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
2424 KB |
Output is correct |
2 |
Correct |
23 ms |
1912 KB |
Output is correct |
3 |
Correct |
84 ms |
8700 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
888 KB |
Output is correct |
6 |
Correct |
15 ms |
1400 KB |
Output is correct |
7 |
Correct |
15 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
3448 KB |
Output is correct |
2 |
Correct |
79 ms |
6520 KB |
Output is correct |
3 |
Correct |
78 ms |
6520 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
35 ms |
6520 KB |
Output is correct |
6 |
Correct |
161 ms |
16828 KB |
Output is correct |
7 |
Correct |
77 ms |
6520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
12664 KB |
Output is correct |
2 |
Correct |
21 ms |
1912 KB |
Output is correct |
3 |
Correct |
10 ms |
888 KB |
Output is correct |
4 |
Correct |
4 ms |
376 KB |
Output is correct |
5 |
Correct |
8 ms |
888 KB |
Output is correct |
6 |
Correct |
159 ms |
12664 KB |
Output is correct |
7 |
Correct |
15 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
1912 KB |
Output is correct |
2 |
Correct |
52 ms |
4472 KB |
Output is correct |
3 |
Correct |
10 ms |
888 KB |
Output is correct |
4 |
Correct |
11 ms |
888 KB |
Output is correct |
5 |
Correct |
41 ms |
6520 KB |
Output is correct |
6 |
Correct |
21 ms |
1916 KB |
Output is correct |
7 |
Correct |
204 ms |
16760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
16888 KB |
Output is correct |
2 |
Correct |
22 ms |
1912 KB |
Output is correct |
3 |
Correct |
10 ms |
888 KB |
Output is correct |
4 |
Correct |
221 ms |
16760 KB |
Output is correct |
5 |
Correct |
49 ms |
8568 KB |
Output is correct |
6 |
Correct |
15 ms |
1400 KB |
Output is correct |
7 |
Correct |
27 ms |
2424 KB |
Output is correct |