Submission #53333

#TimeUsernameProblemLanguageResultExecution timeMemory
53333TAMREFIce Hockey World Championship (CEOI15_bobek)C++11
50 / 100
565 ms21120 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<ll> A, B; int n; ll m; int price_a[20], price_b[20]; int main(){ cin >> n >> m; for(int i = 0; i < n/2; i++){ cin >> price_a[i]; } for(int i = 0; i < (n+1)/2; i++){ cin >> price_b[i]; } for(int b = 0; b < (1 << n/2); b++){ ll subset_sum = 0; for(int i = 0; i < n/2; i++){ if(b >> i & 1){ subset_sum += price_a[i]; } } A.push_back(subset_sum); } for(int b = 0; b < (1 << (n+1)/2); b++){ ll subset_sum = 0; for(int i = 0; i < (n+1)/2; i++){ if(b >> i & 1){ subset_sum += price_b[i]; } } B.push_back(subset_sum); } sort(A.begin(),A.end()); ll ans = 0; for(ll &b : B){ ans += upper_bound(A.begin(),A.end(),m-b) - A.begin(); } cout << ans << '\n'; }
#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...