#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m;
vector<ll> a, b, c;
void brute(int i, int e, ll cost){
if(i == e+1){
b.push_back(cost);
return;
}
brute(i+1, e, cost + a[i]);
brute(i+1, e, cost);
}
int main(){
cin>>n>>m;
a.resize(n);
for(int i = 0; i < n; i++){
cin>>a[i];
}
b.reserve(1000000); c.reserve(1000000);
brute(0, n/2, 0);
c = b;
b.clear();
brute(n/2+1, n-1, 0);
ll ans =0 ;
sort(b.begin(), b.end());
sort(c.begin(), c.end());
int pntr = c.size() - 1;
for(int i = 0; i < b.size(); i++){
while(pntr >= 0 && c[pntr] + b[i] > m){
pntr--;
}
ans += pntr + 1;
}
cout<<ans<<endl;
}
Compilation message
bobek.cpp: In function 'int main()':
bobek.cpp:31:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < b.size(); i++){
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
588 KB |
Output is correct |
3 |
Correct |
2 ms |
672 KB |
Output is correct |
4 |
Correct |
2 ms |
672 KB |
Output is correct |
5 |
Correct |
2 ms |
708 KB |
Output is correct |
6 |
Correct |
2 ms |
708 KB |
Output is correct |
7 |
Correct |
2 ms |
708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
708 KB |
Output is correct |
2 |
Correct |
2 ms |
708 KB |
Output is correct |
3 |
Correct |
2 ms |
708 KB |
Output is correct |
4 |
Correct |
2 ms |
708 KB |
Output is correct |
5 |
Correct |
2 ms |
708 KB |
Output is correct |
6 |
Correct |
2 ms |
708 KB |
Output is correct |
7 |
Correct |
2 ms |
708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
708 KB |
Output is correct |
2 |
Correct |
2 ms |
708 KB |
Output is correct |
3 |
Correct |
3 ms |
708 KB |
Output is correct |
4 |
Correct |
2 ms |
708 KB |
Output is correct |
5 |
Correct |
2 ms |
712 KB |
Output is correct |
6 |
Correct |
2 ms |
716 KB |
Output is correct |
7 |
Correct |
2 ms |
720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
2772 KB |
Output is correct |
2 |
Correct |
76 ms |
8900 KB |
Output is correct |
3 |
Correct |
332 ms |
33756 KB |
Output is correct |
4 |
Correct |
76 ms |
33756 KB |
Output is correct |
5 |
Correct |
15 ms |
33756 KB |
Output is correct |
6 |
Correct |
9 ms |
33756 KB |
Output is correct |
7 |
Correct |
18 ms |
33756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
33756 KB |
Output is correct |
2 |
Correct |
22 ms |
33756 KB |
Output is correct |
3 |
Correct |
129 ms |
33756 KB |
Output is correct |
4 |
Correct |
2 ms |
33756 KB |
Output is correct |
5 |
Correct |
7 ms |
33756 KB |
Output is correct |
6 |
Correct |
18 ms |
33756 KB |
Output is correct |
7 |
Correct |
23 ms |
33756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
33756 KB |
Output is correct |
2 |
Correct |
87 ms |
33756 KB |
Output is correct |
3 |
Correct |
88 ms |
33756 KB |
Output is correct |
4 |
Correct |
2 ms |
33756 KB |
Output is correct |
5 |
Correct |
44 ms |
33756 KB |
Output is correct |
6 |
Correct |
280 ms |
33784 KB |
Output is correct |
7 |
Correct |
85 ms |
33784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
201 ms |
33784 KB |
Output is correct |
2 |
Correct |
22 ms |
33784 KB |
Output is correct |
3 |
Correct |
10 ms |
33784 KB |
Output is correct |
4 |
Correct |
2 ms |
33784 KB |
Output is correct |
5 |
Correct |
8 ms |
33784 KB |
Output is correct |
6 |
Correct |
191 ms |
33784 KB |
Output is correct |
7 |
Correct |
19 ms |
33784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
33784 KB |
Output is correct |
2 |
Correct |
79 ms |
33784 KB |
Output is correct |
3 |
Correct |
10 ms |
33784 KB |
Output is correct |
4 |
Correct |
10 ms |
33784 KB |
Output is correct |
5 |
Correct |
50 ms |
33784 KB |
Output is correct |
6 |
Correct |
21 ms |
33784 KB |
Output is correct |
7 |
Correct |
338 ms |
33784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
343 ms |
33816 KB |
Output is correct |
2 |
Correct |
22 ms |
33816 KB |
Output is correct |
3 |
Correct |
10 ms |
33816 KB |
Output is correct |
4 |
Correct |
357 ms |
33816 KB |
Output is correct |
5 |
Correct |
85 ms |
33816 KB |
Output is correct |
6 |
Correct |
20 ms |
33816 KB |
Output is correct |
7 |
Correct |
37 ms |
33816 KB |
Output is correct |