Submission #941831

# Submission time Handle Problem Language Result Execution time Memory
941831 2024-03-09T14:28:53 Z maxFedorchuk Ice Hockey World Championship (CEOI15_bobek) C++17
40 / 100
1000 ms 456 KB
#include <bits/stdc++.h>
using namespace std;

const long long MX=44;
long long pr[MX],st2[MX],a[MX];

long long cnt(long long n,long long k)
{
    if(n==0 || k<a[1])
    {
        return 1;
    }

    if(pr[n]<=k)
    {
        return st2[n];
    }

    long long o=0;
    if(a[n]<=k)
    {
        o=cnt(n-1,k-a[n]);
    }

    return (o+cnt(n-1,k));
}

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

    long long n,k;
    cin>>n>>k;

    for(long long i=1;i<=n;i++)
    {
        cin>>a[i];
    }

    sort(a+1,a+1+n);

    st2[0]=1;
    for(long long i=1;i<=n;i++)
    {
        pr[i]=pr[i-1]+a[i];
        st2[i]=(st2[i-1]*2);
    }

    cout<<cnt(n,k)<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 388 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 456 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 291 ms 432 KB Output is correct
2 Execution timed out 1058 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 796 ms 448 KB Output is correct
2 Correct 369 ms 436 KB Output is correct
3 Execution timed out 1022 ms 344 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 256 ms 432 KB Output is correct
2 Execution timed out 1095 ms 344 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1037 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -