Submission #977069

# Submission time Handle Problem Language Result Execution time Memory
977069 2024-05-07T11:02:44 Z SeenSiravit Ice Hockey World Championship (CEOI15_bobek) C++14
0 / 100
227 ms 22092 KB
#include<bits/stdc++.h>
#define ll long long

using namespace std;

const int mxN = 40 + 5;

int n;
ll m;
ll a[mxN];

vector<ll> comb_l , comb_r;

void make_combination(){

    int mid = n/2;

    // comb_l [1 , mid]
    int lim = 1<<mid;

    for(int mask=0;mask<lim;mask++){
        ll sum = 0;
        for(int i=0;i<mid;i++){
            if((1<<i) & mask) sum += a[i];
            if(sum > m) break;
        }

        if(sum <= m) comb_l.push_back(sum);
    }

    sort(comb_l.begin() , comb_l.end());

    // comb_r
    lim = 1<<(n-mid);

    for(int mask=0;mask<lim;mask++){
        ll sum = 0;
        for(int i=mid;i<n;i++){
            if((1<<i) & mask) sum += a[i];
            if(sum>m) break;
        }

        if(sum <= m) comb_r.push_back(sum);
    }

    sort(comb_r.begin() , comb_r.end());
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0);

    cin>> n >> m;

    for(int i=0;i<n;i++) cin>> a[i];

    make_combination();

    ll ans = 0;

    for(ll val : comb_r){
        int cnt = upper_bound(comb_l.begin() , comb_l.end() , m - val) - comb_l.begin() - 1;
        ans += cnt;
    }

    cout<< ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 3032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 3688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 153 ms 14384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 2140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 227 ms 22092 KB Output isn't correct
2 Halted 0 ms 0 KB -