Submission #1005011

#TimeUsernameProblemLanguageResultExecution timeMemory
1005011emad234Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
324 ms10484 KiB
#include "bits/stdc++.h" #define F first #define S second #define ll long long #define pii pair<ll,ll> const ll mxN = 2e5 + 5; const ll 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); ll n,m; ll ans = 0; cin >>n>>m; for(ll i = 0;i < n;i++) cin >>a[i]; ll hf = n / 2,sf = (n + 1) / 2; for(ll mask = 0;mask < (1 << hf);mask++){ ll sum = 0; for(ll 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(ll mask = 0;mask < (1 << sf);mask++){ ll sum = 0; for(ll 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...