// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define db long double
#define vll vector<pll>
#define endl '\n'
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int a[45], n, m;
void fmain(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
vi v1, v2;
vi a1, a2;
for(int i = 1; i <= n / 2; i++){
a1.push_back(a[i]);
}
for(int i = n / 2 + 1; i <= n; i++){
a2.push_back(a[i]);
}
for(int mask = 0; mask < (1 << (int)a1.size()); mask++){
int s = 0;
for(int i = 0; i < a1.size(); i++){
if((1 << i) & mask){
s += a1[i];
}
}
v1.push_back(s);
}
for(int mask = 0; mask < (1 << (int)a2.size()); mask++){
int s = 0;
for(int i = 0; i < a2.size(); i++){
if((1 << i) & mask){
s += a2[i];
}
}
v2.push_back(s);
}
sort(all(v2));
int res = 0;
for(int i : v1){
auto ind = upper_bound(all(v2), m - i);
if(ind != v2.begin()) res += ind - v2.begin();
}
cout << res;
}
signed main(){
int tmr = 1;
//cin >> tmr;
while(tmr--){
fmain();
}
}
Compilation message
bobek.cpp: In function 'void fmain()':
bobek.cpp:38:26: 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(int i = 0; i < a1.size(); i++){
| ~~^~~~~~~~~~~
bobek.cpp:47:26: 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]
47 | for(int i = 0; i < a2.size(); i++){
| ~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
1960 KB |
Output is correct |
2 |
Correct |
95 ms |
6592 KB |
Output is correct |
3 |
Correct |
439 ms |
22948 KB |
Output is correct |
4 |
Correct |
96 ms |
6404 KB |
Output is correct |
5 |
Correct |
16 ms |
1480 KB |
Output is correct |
6 |
Correct |
7 ms |
972 KB |
Output is correct |
7 |
Correct |
14 ms |
1480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
2960 KB |
Output is correct |
2 |
Correct |
31 ms |
1868 KB |
Output is correct |
3 |
Correct |
175 ms |
12568 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
6 ms |
972 KB |
Output is correct |
6 |
Correct |
14 ms |
1600 KB |
Output is correct |
7 |
Correct |
13 ms |
1600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
58 ms |
4676 KB |
Output is correct |
2 |
Correct |
132 ms |
8784 KB |
Output is correct |
3 |
Correct |
128 ms |
8772 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
73 ms |
8768 KB |
Output is correct |
6 |
Correct |
231 ms |
22824 KB |
Output is correct |
7 |
Correct |
85 ms |
8764 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
272 ms |
14900 KB |
Output is correct |
2 |
Correct |
26 ms |
1868 KB |
Output is correct |
3 |
Correct |
9 ms |
972 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
6 ms |
972 KB |
Output is correct |
6 |
Correct |
179 ms |
14900 KB |
Output is correct |
7 |
Correct |
13 ms |
1480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
1884 KB |
Output is correct |
2 |
Correct |
84 ms |
6592 KB |
Output is correct |
3 |
Correct |
9 ms |
972 KB |
Output is correct |
4 |
Correct |
9 ms |
1032 KB |
Output is correct |
5 |
Correct |
78 ms |
8764 KB |
Output is correct |
6 |
Correct |
22 ms |
1868 KB |
Output is correct |
7 |
Correct |
215 ms |
22952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
325 ms |
22836 KB |
Output is correct |
2 |
Correct |
29 ms |
1868 KB |
Output is correct |
3 |
Correct |
10 ms |
972 KB |
Output is correct |
4 |
Correct |
419 ms |
22844 KB |
Output is correct |
5 |
Correct |
102 ms |
12724 KB |
Output is correct |
6 |
Correct |
14 ms |
1480 KB |
Output is correct |
7 |
Correct |
27 ms |
2856 KB |
Output is correct |