Submission #85972

#TimeUsernameProblemLanguageResultExecution timeMemory
85972NordwayIce Hockey World Championship (CEOI15_bobek)C++14
20 / 100
624 ms17220 KiB
#include<bits/stdc++.h> using namespace std; long long int n,m,i,j,a[42],mid,sum,ans; vector <long long int> v; int main() { cin>>n>>m; for(i=0;i<n;i++) { cin>>a[i]; } mid=n/2+1; for(i=0;i<(1<<mid);i++) { for(j=0;j<mid;j++) { if((i>>j)&1) { sum+=a[j]; } } v.push_back(sum); sum=0; } int fn=mid; mid=n-mid; sort(v.begin(),v.end()); for(i=0;i<(1<<mid);i++) { for(j=0;j<mid;j++) { if((i>>j)&1) { sum+=a[j+fn]; } } if(sum>m)continue; ans+=upper_bound(v.begin(),v.end(),m-sum)-v.begin(); sum=0; } cout<<ans; return 0; }
#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...