# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
221903 | MKopchev | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 389 ms | 8576 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;
const int nmax=50,MX=(1<<20)+42;
int n;
long long m,inp[nmax];
long long seen[MX];
int pointer=0;
long long output;
void dfs_1(int pos,int target,long long current)
{
if(current>m)return;
if(pos>target)
{
pointer++;
seen[pointer]=current;
return;
}
dfs_1(pos+1,target,current);
dfs_1(pos+1,target,current+inp[pos]);
}
void dfs_2(int pos,int target,long long current)
{
if(current>m)return;
if(pos>target)
{
int pos=upper_bound(seen+1,seen+pointer+1,m-current)-seen;
output=output+pos-1;
return;
}
dfs_2(pos+1,target,current);
dfs_2(pos+1,target,current+inp[pos]);
}
int main()
{
scanf("%i%lld",&n,&m);
for(int i=1;i<=n;i++)scanf("%lld",&inp[i]);
dfs_1(1,n/2,0);
sort(seen+1,seen+pointer+1);
dfs_2(n/2+1,n,0);
printf("%lld\n",output);
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... |