#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int sus[41];
int main(){
ll a,b,n,m;
map<ll, ll> aa, bb;
cin >> n >> m;
FOR(i,0,n) cin >> sus[i];
a = n/2;
b = (n-1)/2 + 1;
FOR(i,0,1<<a){
ll cur = 0, temp = 0, tempi = i;
while (tempi){
if (tempi&1) temp += sus[cur];
cur++;
tempi /=2;
}
aa[temp] += 1;
}
FOR(i,0,1<<b){
ll cur = a, temp = 0, tempi = i;
while (tempi){
if (tempi&1) temp += sus[cur];
cur++;
tempi /=2;
}
bb[temp] += 1;
}
vector<ll> aaa, bbb;
vector<ll> aaa2,bbb2;
ll cur = 0;
for (auto&i : aa){
aaa.push_back(i.first);
aaa2.push_back(i.second);
}
cur = 0;
for (auto&i : bb){
cur += i.second;
bbb.push_back(i.first);
bbb2.push_back(cur);
}
ll ans = 0;
FOR(i,0,aaa.size()){
if (m-aaa[i] < 0) continue;
ll lower = upper_bound(bbb.begin(), bbb.end(), m-aaa[i]) - bbb.begin() - 1;
ans += bbb2[lower] * aaa2[i];
}
cout << ans;
}
Compilation message
bobek.cpp: In function 'int main()':
bobek.cpp:8:35: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
70 | FOR(i,0,aaa.size()){
| ~~~~~~~~~~~~~~
bobek.cpp:70:2: note: in expansion of macro 'FOR'
70 | FOR(i,0,aaa.size()){
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
2344 KB |
Output is correct |
2 |
Correct |
249 ms |
29388 KB |
Output is correct |
3 |
Execution timed out |
1090 ms |
67456 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
3828 KB |
Output is correct |
2 |
Correct |
81 ms |
10796 KB |
Output is correct |
3 |
Correct |
145 ms |
1956 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
5 ms |
212 KB |
Output is correct |
6 |
Correct |
33 ms |
4568 KB |
Output is correct |
7 |
Correct |
55 ms |
10816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
156 ms |
22944 KB |
Output is correct |
2 |
Correct |
265 ms |
23648 KB |
Output is correct |
3 |
Correct |
303 ms |
22872 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
52 ms |
292 KB |
Output is correct |
6 |
Correct |
337 ms |
3444 KB |
Output is correct |
7 |
Correct |
551 ms |
65184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
80 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
107 ms |
276 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |