Submission #1111167

#TimeUsernameProblemLanguageResultExecution timeMemory
1111167Ghulam_JunaidIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
327 ms20904 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll N = 42; ll n, m, a[N]; int main(){ cin >> n >> m; for (ll i=0; i<n; i++) cin >> a[i]; ll x = n / 2; vector<ll> left, right; for (ll mask = 0; mask < (1<<x); mask ++){ ll sm = 0; for (ll i = 0; i < x; i++){ if ((1 << i) & mask){ sm += a[i]; } } left.push_back(sm); } x += n%2; for (ll mask = 0; mask < (1<<x); mask ++){ ll sm = 0; for (ll i = 0; i < x; i++){ if ((1 << i) & mask){ sm += a[i + n / 2]; } } right.push_back(sm); } sort(left.begin(), left.end()); sort(right.begin(), right.end()); ll ans = 0; for (ll x : left){ ll rem = m - x; if (rem < 0) break; ll ub = upper_bound(right.begin(), right.end(), rem) - right.begin(); ans += ub; } 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...