Submission #883288

#TimeUsernameProblemLanguageResultExecution timeMemory
883288votranngocvyIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
288 ms9676 KiB
#include <bits/stdc++.h> using namespace std; #define int long long vector<int>vec; int a[50],n,m,ans; void calcLeft(int i,int sum) { if (i > n / 2) { if (sum <= m) vec.push_back(sum); return; } calcLeft(i + 1,sum); calcLeft(i + 1,sum + a[i]); } int tknp(int l,int r,int x) { int ans = 0; while (l <= r) { int mid = (l + r) / 2; if (vec[mid] <= x) ans = max(ans,mid + 1),l = mid + 1; else r = mid - 1; } return ans; } void calcRight(int i,int sum) { if (i > n) { if (sum <= m) ans += tknp(0,vec.size() - 1,m - sum); return; } calcRight(i + 1,sum); calcRight(i + 1,sum + a[i]); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; calcLeft(1,0); sort(vec.begin(),vec.end()); calcRight(n / 2 + 1,0); 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...