Submission #867388

#TimeUsernameProblemLanguageResultExecution timeMemory
867388Faisal_SaqibIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
408 ms22456 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define int long long signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,m; cin>>n>>m; int a[n]; for(int i=0;i<n;i++) cin>>a[i]; int ans=0; int fn=(n/2); vector<int> fh,sh; for(int mask=0;mask<(1ll<<fn);mask++) { int sum=0; for(int j=0;j<fn;j++) if(mask&(1ll<<j)) sum+=a[j]; if(sum<=m) fh.push_back(sum); } sort(begin(fh),end(fh)); int sn=n-fn; for(int mask=0;mask<(1ll<<sn);mask++) { int sum=0; for(int j=0;j<sn;j++) if(mask&(1ll<<j)) sum+=a[j+fn]; if(sum<=m) sh.push_back(sum); } for(auto i:sh) ans+=upper_bound(begin(fh),end(fh),(m-i))-begin(fh); 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...