Submission #208154

#TimeUsernameProblemLanguageResultExecution timeMemory
208154smhh22Ice Hockey World Championship (CEOI15_bobek)C++11
100 / 100
414 ms16848 KiB
//besmellah #include <bits/stdc++.h> using namespace std; #define int long long int sum[1 << 20], a[40]; vector <int> V; int32_t main() { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; V.push_back(0); for (int mask = 1; mask < (1 << (n / 2)); mask++) { sum[mask] = sum[mask - (mask & -mask)] + a[__builtin_ctz(mask)]; V.push_back(sum[mask]); } sort(V.begin(), V.end()); int ans = 0; ans += upper_bound(V.begin(), V.end(), m) - V.begin(); for (int mask = 1; mask < (1 << ((n + 1) / 2)); mask++) { sum[mask] = sum[mask - (mask & -mask)] + a[n / 2 + __builtin_ctz(mask)]; ans += upper_bound(V.begin(), V.end(), m - sum[mask]) - V.begin(); } cout << ans; }
#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...