Submission #97607

#TimeUsernameProblemLanguageResultExecution timeMemory
97607dalgerokIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
635 ms8788 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n, sz; long long m, x; cin >> n >> m; vector < long long > a, b; for(int i = 0; i < n; i++){ cin >> x; if(i & 1){ a.push_back(x); } else{ b.push_back(x); } } long long ans = 0; sz = (int)a.size(); vector < long long > q; for(int i = 1; i < (1 << sz); i++){ long long sum = 0; for(int j = 0; j < sz; j++){ if((i >> j) & 1){ sum += a[j]; } } if(sum <= m){ ans += 1; q.push_back(sum); } } sort(q.begin(), q.end()); sz = (int)b.size(); for(int i = 1; i < (1 << sz); i++){ long long sum = 0; for(int j = 0; j < sz; j++){ if((i >> j) & 1){ sum += b[j]; } } if(sum <= m){ ans += 1; ans += upper_bound(q.begin(), q.end(), m - sum) - q.begin(); } } cout << ans + 1; }
#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...