Submission #197509

#TimeUsernameProblemLanguageResultExecution timeMemory
197509handlenameIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
557 ms8752 KiB
#include <bits/stdc++.h> using namespace std; long long n,m,total; long long arr[41]; int main() { cin>>n>>m; for (int i=0;i<n;i++) cin>>arr[i]; vector<long long> sums; int fh=n/2; for (int i=0;i<(1<<fh);i++){ long long sum=0; for (int j=0;j<fh;j++){ if (i&(1<<j)) sum+=arr[j]; } sums.push_back(sum); } sort(sums.begin(),sums.end()); int sh=n-fh; for (int i=0;i<(1<<sh);i++){ long long sum=0; for (int j=0;j<sh;j++){ if (i&(1<<j)) sum+=arr[fh+j]; } sum=m-sum; int countt=upper_bound(sums.begin(),sums.end(),sum)-sums.begin(); total+=countt; } cout<<total; }
#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...