# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
155004 | TadijaSebez | Ice Hockey World Championship (CEOI15_bobek) | C++11 | 442 ms | 16892 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N=43;
ll a[N],K;
int n;
vector<ll> Build(int l, int r)
{
int sz=r-l+1;
vector<ll> ans;
ans.reserve(1<<sz);
for(int mask=0;mask<1<<sz;mask++)
{
ll sum=0;
for(int i=0;i<sz;i++) if(mask>>i&1) sum+=a[l+i];
ans.pb(sum);
}
sort(ans.begin(),ans.end());
return ans;
}
int main()
{
scanf("%i %lld",&n,&K);
for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
int m=n/2;
vector<ll> L,R;
L=Build(1,m);
R=Build(m+1,n);
ll ans=0;
for(int i=0;i<L.size();i++)
{
int j=upper_bound(R.begin(),R.end(),K-L[i])-R.begin();
ans+=j;
}
printf("%lld\n",ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |