Submission #928666

#TimeUsernameProblemLanguageResultExecution timeMemory
92866612345678Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
426 ms10696 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int nx=42; ll n, v[nx], m, h, res; vector<ll> s; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>m; for (int i=0; i<n; i++) cin>>v[i]; h=n/2; for (int i=0; i<(1<<h); i++) { ll sm=0; for (int j=0; j<h; j++) if (i&(1<<j)) sm+=v[j]; s.push_back(sm); } sort(s.begin(), s.end()); //for (auto x:s) cout<<x<<'\n'; for (int i=0; i<(1<<(n-h)); i++) { ll sm=0; for (int j=0; j<(n-h); j++) if (i&(1<<j)) sm+=v[h+j]; //cout<<sm<<'\n'; if (sm<=m) res+=(upper_bound(s.begin(), s.end(), m-sm)-s.begin()); } cout<<res; }
#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...