# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43504 | Hassoony | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 623 ms | 33888 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;
typedef long long ll;
const int MX=42;
ll n,m,a[MX];
vector<ll>v1,v2;
void calc(int x,ll sum,int fin){
if(x==fin){
v1.push_back(sum);
return;
}
calc(x+1,sum+a[x],fin);
calc(x+1,sum,fin);
}
ll DP(ll x,ll sum){
if(x==n){
if(sum<=m)return 1;
return 0;
}
ll ret=DP(x+1,sum);
ret+=DP(x+1,sum+a[x]);
return ret;
}
int main(){
scanf("%lld%lld",&n,&m);
for(int i=0;i<n;i++){
scanf("%lld",&a[i]);
}
calc(0,0,n/2+1);
v2=v1;v1.clear();
calc(n/2+1,0,n);
ll ans=0;
sort(v1.begin(),v1.end());
for(auto pp:v2){
if(!pp)continue;
ll idx=upper_bound(v1.begin(),v1.end(),m-pp)-v1.begin();
ans+=idx;
// cout<<pp<<" "<<m-pp<<" "<<idx<<endl;
}
for(auto pp:v1)ans+=(pp<=m);
cout<<ans<<endl;
}
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... |