Submission #1110641

#TimeUsernameProblemLanguageResultExecution timeMemory
1110641basaIce Hockey World Championship (CEOI15_bobek)C++14
0 / 100
28 ms19048 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 += v.size() - it; 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...