Submission #1005009

#TimeUsernameProblemLanguageResultExecution timeMemory
1005009emad234Ice Hockey World Championship (CEOI15_bobek)C++17
50 / 100
323 ms10192 KiB
#include "bits/stdc++.h" #define F first #define S second #define ll long long #define pii pair<ll,ll> const int mxN = 2e5 + 5; const int mod = 1e9 + 7; using namespace std; vector<ll>v; ll a[50]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m; ll ans = 0; cin >>n>>m; for(int i = 0;i < n;i++) cin >>a[i]; int hf = n / 2,sf = (n + 1) / 2; for(int mask = 0;mask < (1 << hf);mask++){ ll sum = 0; for(int i = 0;i < hf;i++){ if((mask >> i) % 2){ sum += a[i]; if(sum > m) break; } } if(sum > m) continue; v.push_back(sum); } // cout<<'\n'; sort(v.begin(),v.end()); // for(auto x : v) cout<<x<<' '; // cout<<'\n'; for(int mask = 0;mask < (1 << sf);mask++){ ll sum = 0; for(int i = 0;i < sf;i++){ if((mask >> i) % 2){ sum += a[i + hf]; if(sum > m) break; } } if(sum > m) continue; ans += upper_bound(v.begin(),v.end(),m - sum) - v.begin(); // cout<<sum<<' '<<upper_bound(v.begin(),v.end(),m - sum) - v.begin()<<'\n'; } cout<<ans; }
#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...