//You can't fill the hole inside you with money, drugs and cars
#include<bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> v, a, b;
void create(int st, int en, vector<long long> &w){
int sz = en - st;
w.push_back(0);
for(int mask = 1; mask < (1 << sz); mask++)
w.push_back(w[mask - (1 << __builtin_ctz(mask))] + v[st + __builtin_ctz(mask)]);
}
long long inp(){
long long A;
cin >> A;
return A;
}
void input(){
cin >> n >> m;
for(int i = 0; i < n; i++)
v.push_back(inp());
}
long long matches(int p1 = 0, int p2 = b.size() - 1, long long ans = 0){
sort(a.begin(), a.end());
sort(b.begin(), b.end());
for(auto A : a){
while(p2 >= 0 and A + b[p2] > m)
p2--;
ans += (p2 + 1);
if(p2 < 0)
break;
}
return ans;
}
long long solve(){
int mid = n / 2;
create(0, mid, a);
create(mid, n, b);
return matches();
}
int main(){
input();
cout << solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
380 KB |
Output is correct |
5 |
Correct |
5 ms |
632 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 |
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 |
21 ms |
2032 KB |
Output is correct |
2 |
Correct |
59 ms |
5476 KB |
Output is correct |
3 |
Correct |
239 ms |
20816 KB |
Output is correct |
4 |
Correct |
58 ms |
5476 KB |
Output is correct |
5 |
Correct |
11 ms |
1652 KB |
Output is correct |
6 |
Correct |
10 ms |
1012 KB |
Output is correct |
7 |
Correct |
16 ms |
1644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
2920 KB |
Output is correct |
2 |
Correct |
24 ms |
2032 KB |
Output is correct |
3 |
Correct |
89 ms |
10588 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
1012 KB |
Output is correct |
6 |
Correct |
16 ms |
1648 KB |
Output is correct |
7 |
Correct |
16 ms |
1648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
3564 KB |
Output is correct |
2 |
Correct |
87 ms |
6624 KB |
Output is correct |
3 |
Correct |
84 ms |
6624 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
40 ms |
6628 KB |
Output is correct |
6 |
Correct |
184 ms |
20816 KB |
Output is correct |
7 |
Correct |
84 ms |
6624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
179 ms |
12756 KB |
Output is correct |
2 |
Correct |
23 ms |
2020 KB |
Output is correct |
3 |
Correct |
10 ms |
1012 KB |
Output is correct |
4 |
Correct |
5 ms |
360 KB |
Output is correct |
5 |
Correct |
8 ms |
1012 KB |
Output is correct |
6 |
Correct |
177 ms |
12756 KB |
Output is correct |
7 |
Correct |
16 ms |
1648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
2032 KB |
Output is correct |
2 |
Correct |
57 ms |
5476 KB |
Output is correct |
3 |
Correct |
12 ms |
1012 KB |
Output is correct |
4 |
Correct |
10 ms |
1012 KB |
Output is correct |
5 |
Correct |
48 ms |
6624 KB |
Output is correct |
6 |
Correct |
22 ms |
2032 KB |
Output is correct |
7 |
Correct |
221 ms |
20820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
225 ms |
20820 KB |
Output is correct |
2 |
Correct |
23 ms |
2032 KB |
Output is correct |
3 |
Correct |
10 ms |
1012 KB |
Output is correct |
4 |
Correct |
258 ms |
20816 KB |
Output is correct |
5 |
Correct |
58 ms |
10588 KB |
Output is correct |
6 |
Correct |
16 ms |
1628 KB |
Output is correct |
7 |
Correct |
28 ms |
2924 KB |
Output is correct |