Submission #484475

#TimeUsernameProblemLanguageResultExecution timeMemory
484475Sho10Ice Hockey World Championship (CEOI15_bobek)C++17
10 / 100
159 ms8632 KiB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho #define ll long long #define double long double #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define aint(a) (a).begin(), (a).end() #define f first #define s second #define pb push_back #define mp make_pair #define pi pair #define rc(s) return cout<<s,0 #define endl '\n' #define mod 998244353 #define PI 3.14159265359 #define INF 1000000005 #define LINF 1000000000000000005ll #define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; ll n,m,a[45]; vector<ll>v; int32_t main(){ CODE_START; cin>>n>>m; for(ll i=0;i<n;i++) { cin>>a[i]; } ll ans=0; ll x=(n+1)/2; ll y=n-x; for(ll i=0;i<(1ll<<y);i++) { ll sum=0; for(ll j=x;j<n;j++) { if(((1ll<<((j-x))&i))){ sum+=a[j]; } } if(sum<=m){ v.pb(sum); } } for(ll i=0;i<(1ll<<x);i++) { ll sum=0; for(ll j=0;j<x;j++) { if((1ll<<j)&i){ sum+=a[j]; } } if(sum>m){ continue; } ll pos=upper_bound(v.begin(),v.end(),m-sum)-v.begin(); if(pos>=1){ ans+=pos; } } cout<<ans<<endl; }
#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...