Submission #870357

#TimeUsernameProblemLanguageResultExecution timeMemory
870357vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
0 / 100
282 ms9160 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n, m; cin >> n >> m; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; vector<int> sums; for (int i = 0; i < (1 << (n / 2)); i++) { int sum = 0; for (int j = 0; j < n / 2; j++) if ((1 << j) & i) sum += a[j]; if (sum <= m) sums.push_back(sum); } sort(sums.begin(),sums.end()); int sz = sums.size(); int cnt = 0; for (int i = 0; i < (1 << (n - n / 2)); i++) { int sum = 0; for (int j = n/2; j < n; j++) if ((1 << j) & i) sum += a[j]; int l = 0, r = sz-1; while (r-l > 1) { int mid = (r+l)/2; if (sums[mid] > m-sum) r = mid; else l = mid; } if (sums[r] <= m-sum) l = r; cnt+=l; } cout << cnt << endl; }
#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...