Submission #87872

#TimeUsernameProblemLanguageResultExecution timeMemory
87872shoemakerjoIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
463 ms21688 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int n; ll m; vector<ll> lsums, rsums; ll ans = 0LL; ll nums[50]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> nums[i]; } int mid = n/2; for (int mask = 0; mask < (1 << mid); mask++) { ll sum = 0LL; for (int i = 1; i <= mid; i++) { if (mask & (1 << (i-1))) { sum += nums[i]; } } lsums.push_back(sum); } int onum = n-mid; for (int mask = 0; mask < (1 << onum); mask++) { ll sum = 0LL; for (int i = mid+1; i <= n; i++) { if (mask & (1 << (i - mid-1))) { sum += nums[i]; } } rsums.push_back(sum); } sort(lsums.begin(), lsums.end()); sort(rsums.begin(), rsums.end()); for (ll val : lsums) { ans += upper_bound(rsums.begin(), rsums.end(), m-val) - rsums.begin() + 0LL; } cout << ans << 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...