Submission #43504

#TimeUsernameProblemLanguageResultExecution timeMemory
43504HassoonyIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
623 ms33888 KiB
#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)

bobek.cpp: In function 'int main()':
bobek.cpp:26:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&m);
                            ^
bobek.cpp:28:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&a[i]);
                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...