#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
using namespace std;
vector<ll> v1;
vector<ll> v2;
ll a[45];
ll clc(int mask,int b,int e,ll m)
{
ll cur=0;
for(int i=b,j=1;i<=e;i++,j++)
{
if((mask>>(j-1))&1)
{
if(cur+a[i]>m)return -1;
cur+=a[i];
}
}
return cur;
}
int main()
{
int n;
cin>>n;
ll m;
cin>>m;
int m1=n/2;
int m2=n-m1;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
for(int i=0;i<(1<<m1)-1;i++)
{
ll c=clc(i,1,m1,m);
if(c!=-1)v1.push_back(c);
}
for(int i=0;i<(1<<m2)-1;i++)
{
ll c=clc(i,m1+1,n,m);
if(c!=-1)v2.push_back(c);
}
sort(v2.begin(),v2.end());
ll rs=0;
for(int i=0;i<v1.size();i++)
{
ll cur=v1[i];
ll r=m-cur;
ll d=upper_bound(v2.begin(),v2.end(),r)-v2.begin();
rs+=d;
}
cout<<rs<<endl;
return 0;
}
Compilation message
bobek.cpp: In function 'int main()':
bobek.cpp:65:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v1.size();i++)
~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
38 ms |
2152 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
53 ms |
2920 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
73 ms |
3588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
380 ms |
12820 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
38 ms |
2024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
469 ms |
20952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |