Submission #130712

#TimeUsernameProblemLanguageResultExecution timeMemory
130712nandonathanielIce Hockey World Championship (CEOI15_bobek)C++14
60 / 100
1090 ms66040 KiB
#include<bits/stdc++.h> using namespace std; typedef long long LL; const LL MOD=1000000007; map<LL,LL> byk; LL a[25],b[25]; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); LL n,m,ans=0; cin >> n >> m; LL first=n/2,second=n-first; for(LL i=0;i<first;i++)cin >> a[i]; for(LL i=0;i<second;i++)cin >> b[i]; for(LL i=0;i<(1<<first);i++){ LL brp=0; for(LL j=0;j<first;j++){ if(i & (1<<j))brp+=a[j]; } byk[brp]++; } for(auto it=byk.begin();it!=byk.end();++it){ if(it==byk.begin())continue; auto prev=it; --prev; byk[it->first]+=byk[prev->first]; } for(LL i=0;i<(1<<second);i++){ LL brp=0; for(LL j=0;j<second;j++){ if(i & (1<<j))brp+=b[j]; } //butuh maksimal m-brp auto butuh=byk.upper_bound(m-brp); if(butuh==byk.begin())continue; --butuh; ans+=(butuh->second); } cout << ans << endl; 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...