#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FORI(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, n) for(ll i = 1; i <= n; i++)
typedef vector<ll> vl;
typedef set<ll> setl;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define pll pair<ll, ll>
#define db double
#define nll cout << "\n"
#define nl "\n"
#define sync ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const ll INF = 1e9 + 7;
const int MAX = 3e5 + 5;
ll n, m, k;
ll a[MAX];
void solve(){
cin >> n >> m;
FOR(i, n)cin >> a[i];
vl v1, v2;
FOR(i, n / 2)v1.push_back(a[i]);
vl a1, a2;
for(ll i = n / 2 + 1; i <= n; i++)v2.push_back(a[i]);
for(ll mask = 0; mask < (1 << v1.size()); mask++){
ll sum = 0;
for(ll i = 0; i < v1.size(); i++){
if((1 << i) & mask)sum += v1[i ];
}
a1.push_back(sum);
}
for(ll mask = 0; mask < (1 << v2.size()); mask++){
ll sum = 0;
for(ll i = 0; i < v2.size(); i++){
if((1 << i) & mask)sum += v2[i];
}
a2.push_back(sum);
}
sort(all(a2));
ll res = 0;
for(auto i : a1){
res += (upper_bound(all(a2), m - i) - a2.begin());
}
cout << res << nl;
}
signed main(){
sync;
ll t = 1;
// cin >> t;
while(t--) {
solve();
}
}
Compilation message
bobek.cpp: In function 'void solve()':
bobek.cpp:31:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(ll i = 0; i < v1.size(); i++){
| ~~^~~~~~~~~~~
bobek.cpp:38:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(ll i = 0; i < v2.size(); i++){
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
0 ms |
336 KB |
Output is correct |
7 |
Correct |
0 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
504 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
504 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
2080 KB |
Output is correct |
2 |
Correct |
93 ms |
6600 KB |
Output is correct |
3 |
Correct |
407 ms |
22960 KB |
Output is correct |
4 |
Correct |
91 ms |
6524 KB |
Output is correct |
5 |
Correct |
13 ms |
1744 KB |
Output is correct |
6 |
Correct |
7 ms |
1104 KB |
Output is correct |
7 |
Correct |
13 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
3020 KB |
Output is correct |
2 |
Correct |
29 ms |
2132 KB |
Output is correct |
3 |
Correct |
168 ms |
12732 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
6 ms |
1104 KB |
Output is correct |
6 |
Correct |
16 ms |
1628 KB |
Output is correct |
7 |
Correct |
13 ms |
1744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
4688 KB |
Output is correct |
2 |
Correct |
132 ms |
8772 KB |
Output is correct |
3 |
Correct |
132 ms |
8804 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
76 ms |
8804 KB |
Output is correct |
6 |
Correct |
210 ms |
22960 KB |
Output is correct |
7 |
Correct |
87 ms |
8780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
275 ms |
14908 KB |
Output is correct |
2 |
Correct |
26 ms |
2132 KB |
Output is correct |
3 |
Correct |
10 ms |
1104 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
7 ms |
1092 KB |
Output is correct |
6 |
Correct |
181 ms |
14912 KB |
Output is correct |
7 |
Correct |
13 ms |
1912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
2132 KB |
Output is correct |
2 |
Correct |
89 ms |
6560 KB |
Output is correct |
3 |
Correct |
9 ms |
1104 KB |
Output is correct |
4 |
Correct |
9 ms |
992 KB |
Output is correct |
5 |
Correct |
87 ms |
8564 KB |
Output is correct |
6 |
Correct |
22 ms |
2132 KB |
Output is correct |
7 |
Correct |
217 ms |
22960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
329 ms |
22960 KB |
Output is correct |
2 |
Correct |
29 ms |
2132 KB |
Output is correct |
3 |
Correct |
9 ms |
1104 KB |
Output is correct |
4 |
Correct |
421 ms |
22972 KB |
Output is correct |
5 |
Correct |
104 ms |
12728 KB |
Output is correct |
6 |
Correct |
14 ms |
1744 KB |
Output is correct |
7 |
Correct |
26 ms |
3020 KB |
Output is correct |