Submission #377307

#TimeUsernameProblemLanguageResultExecution timeMemory
377307gustasonIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
538 ms25100 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; ll m; cin >> n >> m; vector<ll> l, r; for(int i = 0; i < n; i++) { ll x; cin >> x; if (i > n/2) { r.push_back(x); } else { l.push_back(x); } } vector<ll> ls, rs; const int ln = l.size(), rn = r.size(); for(int mask = 0; mask < (1 << ln); mask++) { ll sum = 0; for(int i = 0; i < ln; i++) { if (mask & (1 << i)) { sum += l[i]; } } ls.push_back(sum); } for(int mask = 0; mask < (1 << rn); mask++) { ll sum = 0; for(int i = 0; i < rn; i++) { if (mask & (1 << i)) { sum += r[i]; } } rs.push_back(sum); } ll ans = 0; sort(ls.begin(), ls.end()); sort(rs.begin(), rs.end()); for(ll i : ls) { ll idx = upper_bound(rs.begin(), rs.end(), m - i) - rs.begin(); ans += idx; } 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...