#include <bits/stdc++.h>
using namespace std;
int n;
long long m, va[2][25], s[2], ans;
vector<long long> all[2];
void permute( int ty, int now, int ok, long long sum = 0 ) {
if( ok ) sum += va[0][now];
if( now == s[ty] ) {
all[ty].emplace_back( sum );
return ;
}
permute( ty, now+1, 0, sum ), permute( ty, now+1, 1, sum );
}
int main()
{
scanf("%d %lld",&n,&m);
s[0] = n/2;
s[1] = n - s[0];
for( int i = 1 ; i <= s[0] ; i++ ) scanf("%lld",&va[0][i]);
for( int i = 1 ; i <= s[1] ; i++ ) scanf("%lld",&va[1][i]);
permute( 0, 1, 0 ), permute( 0, 1, 1 );
permute( 1, 1, 0 ), permute( 1, 1, 1 );
sort( all[0].begin(), all[0].end() ), sort( all[1].begin(), all[1].end() );
for( long long i : all[0] ) {
long long temp = m - i;
int idx = upper_bound( all[1].begin(), all[1].end(), temp ) - all[1].begin();
ans += ( long long )idx;
}
printf("%lld",ans);
return 0;
}
Compilation message
bobek.cpp: In function 'int main()':
bobek.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %lld",&n,&m);
~~~~~^~~~~~~~~~~~~~~~~
bobek.cpp:23:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for( int i = 1 ; i <= s[0] ; i++ ) scanf("%lld",&va[0][i]);
~~~~~^~~~~~~~~~~~~~~~~~
bobek.cpp:24:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for( int i = 1 ; i <= s[1] ; i++ ) scanf("%lld",&va[1][i]);
~~~~~^~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
776 ms |
1048580 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
2040 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
2932 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
3572 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
201 ms |
12780 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
2040 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
294 ms |
20824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |