Submission #85969

#TimeUsernameProblemLanguageResultExecution timeMemory
85969NordwayIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
597 ms9244 KiB
#include<bits/stdc++.h> #define x first #define y second #define pb push_back #define mp make_pair #define up_b upper_bound #define low_b lower_bound #define sz(x) (int)x.size() #define all(v) v.begin(),v.end() #define boost ios_base::sync_with_stdio(0),cin.tie(0) #define FILE "divide" using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<int,ll> pil; typedef pair<ll,int> pli; typedef pair<ll,ll> pll; const int mod=1e9+7; const int inf=1e9; const ll INF=1e18; const ld pi=acos(-1); const int N=41; ll a[N]; int main(){ /*freopen(FILE".in","r",stdin); freopen(FILE".out","w",stdout);*/ int n; ll m; cin>>n>>m; for(int i=0;i<n;i++){ cin>>a[i]; } int fn=(n+1)/2; int sn=n-fn; vector<ll>v; for(int mask=0;mask<(1<<fn);mask++){ ll sum=0; for(int i=0;i<fn;i++){ if((mask>>i)&1)sum+=a[i]; } if(sum>m)continue; v.pb(sum); } sort(all(v)); ll ans=0; for(int mask=0;mask<(1<<sn);mask++){ ll sum=0; for(int i=0;i<sn;i++){ if((mask>>i)&1)sum+=a[fn+i]; } if(sum>m)continue; int pos=up_b(all(v),m-sum)-v.begin(); ans+=pos; } 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...