Submission #919791

#TimeUsernameProblemLanguageResultExecution timeMemory
919791VMaksimoski008Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
336 ms22700 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() using namespace std; using ll = long long; int32_t main() { int n; ll m, ans = 1; cin >> n >> m; vector<ll> v(n); for(ll &x : v) cin >> x; auto meet = [&](int l, int r) { vector<ll> total; int len = r - l + 1; for(int s=1; s<(1<<len); s++) { ll sum = 0; for(int i=0; i<len; i++) if(s & (1 << i)) sum += v[l+i]; total.push_back(sum); if(sum <= m) ans++; } sort(all(total)); return total; }; vector<ll> L = meet(0, n/2-1); vector<ll> R = meet(n/2, n-1); for(ll &x : L) { int l=0, r=R.size()-1, p=-1; while(l <= r) { int mid = (l + r) / 2; if(x + R[mid] <= m) p = mid, l = mid + 1; else r = mid - 1; } ans += p + 1; } 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...