Submission #941839

#TimeUsernameProblemLanguageResultExecution timeMemory
941839maxFedorchukIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
289 ms10700 KiB
#include <bits/stdc++.h> using namespace std; vector < long long > vr1; long long a[44]; long long ans,n,k; void cnt1(long long zr,long long sm) { if(zr==(n/2+1)) { vr1.push_back(sm); return; } cnt1(zr+1,sm+a[zr]); cnt1(zr+1,sm); } void cnt2(long long zr,long long sum) { if(zr==n+1) { ans+=(upper_bound(vr1.begin(),vr1.end(),k-sum)-vr1.begin()); return; } cnt2(zr+1,sum+a[zr]); cnt2(zr+1,sum); } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>k; for(long long i=1;i<=n;i++) { cin>>a[i]; } cnt1(1,0); sort(vr1.begin(),vr1.end()); cnt2(n/2+1,0); cout<<ans<<"\n"; 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...