Submission #445911

#TimeUsernameProblemLanguageResultExecution timeMemory
445911snasibov05Ice Hockey World Championship (CEOI15_bobek)C++14
0 / 100
443 ms16756 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define ll long long #define pb push_back int main() { int n; ll m; cin >> n >> m; vector<ll> v(n); for (int i = 0; i < n; ++i) { cin >> v[i]; } int mid = (n-1) / 2; vector<ll> p1; p1.pb(0); for (int i = 0; i < (1 << (mid+1)); ++i) { ll sum = 0; int x = i; for (int j = 0; j <= mid; ++j) { if (x % 2 == 1) sum += v[j]; x /= 2; } if (sum <= m) p1.pb(sum); } sort(p1.begin(), p1.end()); ll ans = p1.size(); for (int i = 0; i < (1 << (n - mid - 1)); ++i) { ll sum = 0; int x = i; for (int j = mid + 1; j < n; ++j) { if (x % 2 == 1) sum += v[j]; x /= 2; } if (sum > m) continue; int k = upper_bound(p1.begin(), p1.end(), m - sum) - p1.begin(); ans += 1ll * k; } ans /= 2; cout << ans << "\n"; 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...