#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
#define read2(a,b) read(a),read(b)
#define read3(a,b,c) read(a),read(b),read(c)
const int N=42;
int n,m,x[N];
ll a[N],kq;
vector<ll> e;
void duyet(int i,int l,int s)
{
if(i==l+1)
{
if(l==n/2) e.pb(s);
else kq+=upper_bound(all(e),m-s)-e.begin();
return;
}
duyet(i+1,l,s);
duyet(i+1,l,s+a[i]);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen("BOBEK.inp","r",stdin);
cin>>n>>m;
forinc(i,1,n) cin>>a[i];
duyet(1,n/2,0);
sort(all(e));
duyet(n/2+1,n,0);
cout<<kq;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1024 KB |
Output is correct |
2 |
Correct |
83 ms |
2572 KB |
Output is correct |
3 |
Correct |
415 ms |
8688 KB |
Output is correct |
4 |
Correct |
75 ms |
2552 KB |
Output is correct |
5 |
Correct |
13 ms |
1024 KB |
Output is correct |
6 |
Correct |
6 ms |
768 KB |
Output is correct |
7 |
Correct |
10 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
1532 KB |
Output is correct |
2 |
Correct |
22 ms |
1024 KB |
Output is correct |
3 |
Correct |
174 ms |
4596 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
768 KB |
Output is correct |
6 |
Correct |
11 ms |
1024 KB |
Output is correct |
7 |
Correct |
10 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
1532 KB |
Output is correct |
2 |
Correct |
147 ms |
2552 KB |
Output is correct |
3 |
Correct |
149 ms |
2552 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
37 ms |
2560 KB |
Output is correct |
6 |
Correct |
154 ms |
8688 KB |
Output is correct |
7 |
Correct |
42 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
73 ms |
4596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
1024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
103 ms |
8636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |