Submission #82961

# Submission time Handle Problem Language Result Execution time Memory
82961 2018-11-03T09:54:31 Z Vasiljko Ice Hockey World Championship (CEOI15_bobek) C++14
90 / 100
291 ms 21512 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 50;

int n;
ll m,a[N],b[N],ans;
vector<ll>S1,S2;

void Fill(vector<ll>&S,int ind,int len,ll sum){
    if(ind==len+1){
        S.push_back(sum);
        return;
    }
    Fill(S,ind+1,len,sum);
    if(sum+b[ind]<=m)Fill(S,ind+1,len,sum+b[ind]);
}

void Gen(vector<ll>&S,int len){
    Fill(S,1,len,0);
}


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }

    if(n==1){
        if(a[1]<=m)cout<<1;
        else cout<<0;
        return 0;
    }

    int len=n/2;

    for(int i=1;i<=n/2;i++)b[i]=a[i];
    Fill(S1,1,len,0);
    for(int i=n/2+1;i<=n;i++)b[i-n/2]=a[i];
    Fill(S2,1,n-len,0);

    sort(S1.begin(),S1.end());
    sort(S2.begin(),S2.end());
    reverse(S2.begin(),S2.end());

    int prev=0;
    for(auto e:S2){
        ll val=m-e;
        int l=prev;
        int r=(int)S1.size()-1;
        int sol=0;

        while(l<=r){
            int mid=(l+r)>>1;
            if(S1[mid]<=val){
                sol=mid;
                l=mid+1;
            }else{
                r=mid-1;
            }
        }
        prev=sol;
        ans+=1LL*(sol+1);
    }

    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 2 ms 732 KB Output is correct
5 Correct 2 ms 828 KB Output is correct
6 Correct 2 ms 828 KB Output is correct
7 Correct 2 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 828 KB Output is correct
2 Correct 3 ms 828 KB Output is correct
3 Correct 2 ms 828 KB Output is correct
4 Correct 2 ms 828 KB Output is correct
5 Correct 2 ms 828 KB Output is correct
6 Correct 3 ms 828 KB Output is correct
7 Correct 2 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 828 KB Output is correct
2 Correct 3 ms 828 KB Output is correct
3 Correct 2 ms 828 KB Output is correct
4 Correct 2 ms 828 KB Output is correct
5 Correct 2 ms 828 KB Output is correct
6 Correct 3 ms 828 KB Output is correct
7 Correct 2 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2480 KB Output is correct
2 Correct 66 ms 5932 KB Output is correct
3 Correct 284 ms 21276 KB Output is correct
4 Correct 71 ms 21276 KB Output is correct
5 Correct 12 ms 21276 KB Output is correct
6 Correct 8 ms 21276 KB Output is correct
7 Correct 2 ms 21276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 21276 KB Output is correct
2 Correct 24 ms 21276 KB Output is correct
3 Correct 108 ms 21276 KB Output is correct
4 Correct 3 ms 21276 KB Output is correct
5 Correct 6 ms 21276 KB Output is correct
6 Correct 14 ms 21276 KB Output is correct
7 Correct 2 ms 21276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 21276 KB Output is correct
2 Correct 101 ms 21276 KB Output is correct
3 Correct 101 ms 21276 KB Output is correct
4 Correct 2 ms 21276 KB Output is correct
5 Correct 84 ms 21276 KB Output is correct
6 Correct 206 ms 21400 KB Output is correct
7 Correct 2 ms 21400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 206 ms 21400 KB Output is correct
2 Correct 23 ms 21400 KB Output is correct
3 Correct 9 ms 21400 KB Output is correct
4 Correct 2 ms 21400 KB Output is correct
5 Correct 6 ms 21400 KB Output is correct
6 Correct 180 ms 21400 KB Output is correct
7 Correct 2 ms 21400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 21400 KB Output is correct
2 Correct 65 ms 21400 KB Output is correct
3 Correct 8 ms 21400 KB Output is correct
4 Correct 12 ms 21400 KB Output is correct
5 Correct 65 ms 21400 KB Output is correct
6 Correct 21 ms 21400 KB Output is correct
7 Correct 2 ms 21400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 268 ms 21432 KB Output is correct
2 Correct 32 ms 21432 KB Output is correct
3 Correct 9 ms 21432 KB Output is correct
4 Correct 291 ms 21512 KB Output is correct
5 Correct 83 ms 21512 KB Output is correct
6 Correct 16 ms 21512 KB Output is correct
7 Correct 3 ms 21512 KB Output is correct