Submission #1110644

#TimeUsernameProblemLanguageResultExecution timeMemory
1110644basaIce Hockey World Championship (CEOI15_bobek)C++14
0 / 100
27 ms18880 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define mod 1000000007 const int maxn = 45; int a[maxn]; int n, m; int ans = 0; vector<int>v; void s1(int i, int sum){ if(i == (n / 2) + 1){ v.push_back(sum); return; } s1(i + 1, sum); s1(i + 1, sum + a[i]); } void s2(int i, int sum){ if(i == n){ auto it = upper_bound(v.begin(), v.end(), m - sum) - v.begin(); ans += it - 1; return; } s2(i + 1, sum); s2(i + 1, sum + a[i]); } signed main(){ cin.tie(0) -> sync_with_stdio(0); cin >> n >> m; for(int i = 0; i < n; i++) cin >> a[i]; s1(0, 0); s2((n / 2) + 1, 0); 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...