Submission #24548

#TimeUsernameProblemLanguageResultExecution timeMemory
24548BruteforcemanIce Hockey World Championship (CEOI15_bobek)C++11
100 / 100
446 ms26680 KiB
#include "bits/stdc++.h" using namespace std; void putStaff(vector <long long> v, vector <long long> &x) { int n = v.size(); for(int i = 0; i < (1 << n); i++) { long long sum = 0; for(int j = 0; j < n; j++) { if((i >> j) & 1) { sum += v[j]; } } x.push_back(sum); } sort(x.begin(), x.end()); } int main(int argc, char const *argv[]) { int n; long long budget; cin >> n >> budget; long long *a = new long long [n]; for(int i = 0; i < n; i++) { cin >> a[i]; } int half = n >> 1; vector <long long> p1, p2; vector <long long> sum1, sum2; for(int i = 0; i < n; i++) { if(i < half) p1.push_back(a[i]); else p2.push_back(a[i]); } delete a; putStaff(p1, sum1); putStaff(p2, sum2); long long ans = 0; for(auto i : sum1) { ans += upper_bound(sum2.begin(), sum2.end(), budget - i) - sum2.begin(); } cout << ans << endl; return 0; }
#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...