Submission #1004996

#TimeUsernameProblemLanguageResultExecution timeMemory
1004996SulAIce Hockey World Championship (CEOI15_bobek)C++17
50 / 100
302 ms6604 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int 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<int> half; for (int mask = 0; mask < 1 << (n/2); mask++) { long long sum = 0; for (int 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 (int mask = 0; mask < (1 << ((n+1)/2)); mask++) { long long sum = 0; for (int 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...