Submission #760766

#TimeUsernameProblemLanguageResultExecution timeMemory
760766BidoTeimaIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
429 ms8648 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int mod = 1e9 + 7; int main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int n; ll m; cin>>n>>m; ll a[n]; for(int i = 0; i < n; i++)cin>>a[i]; // [0, n / 2 - 1], [n / 2, n - 1] vector<ll>v; for(int mask = 0; mask < (1 << ((n+1)>>1)); mask++){ ll sum = 0; for(int i = 0; i < (n+1)/2; i++){ if(mask & (1 << i)) sum += a[i + (n >> 1)]; } v.push_back(sum); } sort(v.begin(), v.end()); ll ans = 0; for(int mask = 0; mask < (1 << (n >> 1)); mask++){ ll sum = 0; for(int i = 0; i < (n >> 1); i++){ if(mask & (1 << i)) sum += a[i]; } ans += upper_bound(v.begin(), v.end(), m - sum) - v.begin(); } cout<<ans; 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...