Submission #208152

#TimeUsernameProblemLanguageResultExecution timeMemory
208152alidoostiIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
571 ms8684 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int maxn = 42; int n, m, ans, a[maxn]; vector <int> v; int32_t main() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int msk = 0; msk < (1 << (n / 2)); msk++) { int S = 0; for (int j = 0; j < n / 2; j++) { if (msk & (1 << j)) S += a[j]; } v.push_back(S); } sort(v.begin(), v.end()); for (int msk = 0; msk < (1 << (n - (n / 2))); msk++) { int S = 0; for (int j = 0; j < n - (n / 2); j++) { if (msk & (1 << j)) S += a[j + (n / 2)]; } ans += upper_bound(v.begin(), v.end(), m - S) - v.begin(); } cout << ans; 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...