Submission #1054108

#TimeUsernameProblemLanguageResultExecution timeMemory
1054108matereIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
255 ms22488 KiB
#include<bits/stdc++.h> using namespace std; long long n,n1,n2,m,a[21],b[21]; vector<long long>v1,v2; int main(){ cin>>n>>m; n1=n/2; n2=n-n/2; for(int i=1;i<=n1;i++){ cin>>a[i]; } for(int i=1;i<=n2;i++){ cin>>b[i]; } for(int i=0;i<(1ll<<n1);i++){ long long sum=0; for(int j=0;j<n1;j++){ if(i&(1ll<<j)){ sum+=a[j+1]; } } v1.push_back(sum); } for(int i=0;i<(1ll<<n2);i++){ long long sum=0; for(int j=0;j<n2;j++){ if(i&(1ll<<j)){ sum+=b[j+1]; } } v2.push_back(sum); } sort(v1.begin(),v1.end()); sort(v2.begin(),v2.end()); long long ans=0; for(long long i:v1){ ans+=upper_bound(v2.begin(),v2.end(),m-i)-v2.begin(); } cout<<ans<<endl; }
#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...