Submission #101693

#TimeUsernameProblemLanguageResultExecution timeMemory
101693lycIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
676 ms8704 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { //freopen("in.txt", "r", stdin); ios::sync_with_stdio(false); cin.tie(0); int n; ll m; cin >> n >> m; ll a[n]; for (int i = 0; i < n; ++i) { cin >> a[i]; } vector<ll> v; int s = n/2; for (int i = 0; i < (1<<s); ++i) { ll cur = 0; for (int j = 0; j < s; ++j) if (i & (1<<j)) cur += a[j]; v.push_back(cur); } sort(v.begin(), v.end()); ll ans = 0; for (int i = 0; i < (1<<(n-s)); ++i) { ll cur = 0; for (int j = s; j < n; ++j) if (i & (1<<(j-s))) cur += a[j]; ll maxi = m - cur; ans += upper_bound(v.begin(), v.end(), maxi) - v.begin(); } cout << ans << '\n'; }
#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...