Submission #484475

# Submission time Handle Problem Language Result Execution time Memory
484475 2021-11-03T16:14:01 Z Sho10 Ice Hockey World Championship (CEOI15_bobek) C++17
10 / 100
159 ms 8632 KB
#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 time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 1484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 4520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 848 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 159 ms 8632 KB Output isn't correct
2 Halted 0 ms 0 KB -