Submission #1109820

#TimeUsernameProblemLanguageResultExecution timeMemory
1109820SulAIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
376 ms10692 KiB
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long n; long long x; cin >> n >> x; long long a1[n/2], a2[(n+1)/2]; for (auto& y : a1) cin >> y; for (auto& y : a2) cin >> y; vector<long long> half; for (long long mask = 0; mask < 1 << (n/2); mask++) { long long sum = 0; for (long long i = 0; i < n/2; i++) { if (mask & (1 << i)) { sum += a1[i]; } } if (sum <= x) half.push_back(sum); } sort(half.begin(), half.end()); long long cnt = 0; for (long long mask = 0; mask < (1 << ((n+1)/2)); mask++) { long long sum = 0; for (long long i = 0; i < (n+1)/2; i++) { if (mask & (1 << i)) { sum += a2[i]; } } if (sum <= x) cnt += upper_bound(half.begin(), half.end(), x - sum) - half.begin(); } cout << cnt; }
#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...