#pragma GCC optimize(" unroll-loops")
#pragma gcc optimize("Ofast")
#pragma GCC optimization("Ofast")
#pragma optimize(Ofast)
#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)
ll sus[41];
int main(){
ll a,b,n,m;
//map<ll, ll> aa, bb;
vector<ll> aaa, bbb;
vector<ll> aaa2,bbb2;
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>>=1;
}
//aa[temp] += 1;
aaa.push_back(temp);
}
FOR(i,0,1<<b){
ll cur = a, temp = 0, tempi = i;
while (tempi){
if (tempi&1) temp += sus[cur];
cur++;
tempi>>=1;
}
//bb[temp] += 1;
bbb.push_back(temp);
}
// 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);
// }
sort(aaa.begin(), aaa.end());
sort(bbb.begin(), bbb.end());
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();
ans += lower;
}
cout << ans;
}
Compilation message
bobek.cpp:2: warning: ignoring '#pragma gcc optimize' [-Wunknown-pragmas]
2 | #pragma gcc optimize("Ofast")
|
bobek.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
3 | #pragma GCC optimization("Ofast")
|
bobek.cpp:4: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
4 | #pragma optimize(Ofast)
|
bobek.cpp:1:37: warning: bad option '-f unroll-loops' to pragma 'optimize' [-Wpragmas]
1 | #pragma GCC optimize(" unroll-loops")
| ^
bobek.cpp:18:10: warning: bad option '-f unroll-loops' to attribute 'optimize' [-Wattributes]
18 | int main(){
| ^
bobek.cpp: In function 'int main()':
bobek.cpp:12: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]
12 | #define FOR(i, x, y) for(ll i=x; i<y; i++)
......
80 | FOR(i,0,aaa.size()){
| ~~~~~~~~~~~~~~
bobek.cpp:80:2: note: in expansion of macro 'FOR'
80 | 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 |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 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 |
Correct |
26 ms |
1956 KB |
Output is correct |
2 |
Correct |
79 ms |
5324 KB |
Output is correct |
3 |
Correct |
323 ms |
20716 KB |
Output is correct |
4 |
Correct |
76 ms |
5372 KB |
Output is correct |
5 |
Correct |
13 ms |
1484 KB |
Output is correct |
6 |
Correct |
8 ms |
940 KB |
Output is correct |
7 |
Correct |
16 ms |
1484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
2876 KB |
Output is correct |
2 |
Correct |
27 ms |
1944 KB |
Output is correct |
3 |
Correct |
130 ms |
10496 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
8 ms |
852 KB |
Output is correct |
6 |
Correct |
19 ms |
1484 KB |
Output is correct |
7 |
Correct |
17 ms |
1488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
3544 KB |
Output is correct |
2 |
Correct |
112 ms |
6592 KB |
Output is correct |
3 |
Correct |
117 ms |
6584 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
71 ms |
6516 KB |
Output is correct |
6 |
Correct |
270 ms |
20756 KB |
Output is correct |
7 |
Correct |
98 ms |
6584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
256 ms |
12696 KB |
Output is correct |
2 |
Correct |
26 ms |
1872 KB |
Output is correct |
3 |
Correct |
9 ms |
852 KB |
Output is correct |
4 |
Correct |
1 ms |
304 KB |
Output is correct |
5 |
Correct |
6 ms |
916 KB |
Output is correct |
6 |
Correct |
229 ms |
12676 KB |
Output is correct |
7 |
Correct |
15 ms |
1596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
1872 KB |
Output is correct |
2 |
Correct |
74 ms |
5364 KB |
Output is correct |
3 |
Correct |
8 ms |
852 KB |
Output is correct |
4 |
Correct |
8 ms |
852 KB |
Output is correct |
5 |
Correct |
77 ms |
6576 KB |
Output is correct |
6 |
Correct |
27 ms |
1872 KB |
Output is correct |
7 |
Correct |
282 ms |
20768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
309 ms |
20712 KB |
Output is correct |
2 |
Correct |
27 ms |
1872 KB |
Output is correct |
3 |
Correct |
9 ms |
852 KB |
Output is correct |
4 |
Correct |
317 ms |
20772 KB |
Output is correct |
5 |
Correct |
101 ms |
10532 KB |
Output is correct |
6 |
Correct |
16 ms |
1484 KB |
Output is correct |
7 |
Correct |
33 ms |
2760 KB |
Output is correct |