#include <cstdio>
#include <vector>
#include <algorithm>
typedef long long lint;
using namespace std;
vector<lint> v1, v2;
lint a[41], m;
void dfs(lint x, int pos, int lim, vector<lint> &v){
if(pos == lim){
v.push_back(x);
return;
}
dfs(x + a[pos], pos+1, lim, v);
dfs(x, pos + 1, lim, v);
}
int n;
int main(){
scanf("%d %lld",&n,&m);
for(int i=0; i<n; i++){
scanf("%lld",&a[i]);
}
dfs(0, 0, n/2, v1);
dfs(0, n/2, n, v2);
sort(v2.begin(), v2.end());
lint ret = 0;
for(auto &i : v1){
ret += (int)(upper_bound(v2.begin(), v2.end(), m - i) - v2.begin());
}
printf("%lld",ret);
}
Compilation message
bobek.cpp: In function 'int main()':
bobek.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("%d %lld",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~~~
bobek.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
25 | scanf("%lld",&a[i]);
| ~~~~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
420 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
428 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
1880 KB |
Output is correct |
2 |
Correct |
60 ms |
5320 KB |
Output is correct |
3 |
Correct |
291 ms |
21188 KB |
Output is correct |
4 |
Correct |
55 ms |
5324 KB |
Output is correct |
5 |
Correct |
5 ms |
1492 KB |
Output is correct |
6 |
Correct |
4 ms |
984 KB |
Output is correct |
7 |
Correct |
6 ms |
1492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
2764 KB |
Output is correct |
2 |
Correct |
18 ms |
1880 KB |
Output is correct |
3 |
Correct |
121 ms |
11464 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
984 KB |
Output is correct |
6 |
Correct |
6 ms |
1492 KB |
Output is correct |
7 |
Correct |
5 ms |
1492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
3580 KB |
Output is correct |
2 |
Correct |
84 ms |
7056 KB |
Output is correct |
3 |
Correct |
82 ms |
8344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
30 ms |
6868 KB |
Output is correct |
6 |
Correct |
92 ms |
21016 KB |
Output is correct |
7 |
Correct |
42 ms |
7248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
178 ms |
13388 KB |
Output is correct |
2 |
Correct |
16 ms |
1880 KB |
Output is correct |
3 |
Correct |
5 ms |
984 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
2 ms |
984 KB |
Output is correct |
6 |
Correct |
91 ms |
13608 KB |
Output is correct |
7 |
Correct |
6 ms |
1492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
1880 KB |
Output is correct |
2 |
Correct |
54 ms |
5548 KB |
Output is correct |
3 |
Correct |
5 ms |
984 KB |
Output is correct |
4 |
Correct |
5 ms |
984 KB |
Output is correct |
5 |
Correct |
32 ms |
7760 KB |
Output is correct |
6 |
Correct |
13 ms |
1880 KB |
Output is correct |
7 |
Correct |
112 ms |
22980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
199 ms |
21184 KB |
Output is correct |
2 |
Correct |
18 ms |
1880 KB |
Output is correct |
3 |
Correct |
5 ms |
984 KB |
Output is correct |
4 |
Correct |
296 ms |
22716 KB |
Output is correct |
5 |
Correct |
41 ms |
11972 KB |
Output is correct |
6 |
Correct |
6 ms |
1492 KB |
Output is correct |
7 |
Correct |
11 ms |
2768 KB |
Output is correct |