# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40517 | Pajaraja | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 618 ms | 9044 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;
long long a[40],c[2000000];
long long binarna(int l,int r,long long val)
{
if(l==r) return l;
int s=(l+r)/2;
if(c[s]>val) return binarna(l,s,val);
return binarna(s+1,r,val);
}
int main()
{
int n;
long long m,sol=0;
scanf("%d %lld",&n,&m);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int p=n/2;
for(int i=0;i<(1<<p);i++)
{
int ma=i;
long long pr=0;
for(int j=0;j<p;j++)
{
if(ma%2==0) pr+=a[j];
ma/=2;
}
c[i]=pr;
}
c[1<<p]=2000000000000000000LL;
sort(c,c+(1<<p)+1);
int q=n-p;
for(int i=0;i<(1<<q);i++)
{
int ma=i;
long long pr=0;
for(int j=0;j<q;j++)
{
if(ma%2==0) pr+=a[p+j];
ma/=2;
}
sol+=binarna(0,(1<<p),m-pr);
}
printf("%lld",sol);
}
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... |