Submission #484472

#TimeUsernameProblemLanguageResultExecution timeMemory
484472Sho10Ice Hockey World Championship (CEOI15_bobek)C++17
10 / 100
163 ms8680 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=1;i<=n;i++) { cin>>a[i]; } ll ans=0; ll x=(n+1)/2; for(ll i=0;i<(1ll<<x);i++) { ll sum=0; for(ll j=1;j<=x;j++) { if(((1ll<<(j-1))&i)){ sum+=a[j]; } } if(sum<=m){ ans++; // cout<<sum<<' '<<i<<endl; v.pb(sum); } } ll y=n-x; for(ll i=1;i<(1ll<<y);i++) { ll sum=0; for(ll j=x+1;j<=n;j++) { ll pos=j-x; pos--; if((1ll<<pos)&i){ sum+=a[j]; } } if(sum>m){ continue; } ll pos=upper_bound(v.begin(),v.end(),m-sum)-v.begin(); // cout<<pos<<endl; 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...