Submission #857254


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,t,a[51],dp[51][51][2501];

ll solve(ll i, ll c, ll sum, ll m)
{
    if(i>n)
    {
//        if(c==0)
//            return 0;
        //cout<<sum<<" "<<c<<" "<<m<<endl;
        if(sum==m*c && c!=0)
            return 1;
        else return 0;
    }

    if(dp[i][c][sum]!=-1)return dp[i][c][sum];

    ll r1=0,r2=0;

    r1=solve(i+1,c+1,sum+a[i],m);

    r2=solve(i+1,c,sum,m);
    //cout<<" r1= "<<r1<<" r2= "<<r2<<endl;
    return dp[i][c][sum]=r1+r2;
}

int main()
{
    ll i,j,k,l,ans=0;

    scanf("%lld %lld",&n,&t);

    for(i=1; i<=n; i++)
        scanf("%lld",&a[i]);


    for(i=0; i<51; i++)
    {
        for(l=0; l<51; l++)
        {
            for(j=0; j<2501; j++)
                dp[i][l][j]=-1;
        }
    }
    ans+=solve(1,0,0,t);

    printf("%lld\n",ans);

    return 0;
}

Submission Info

Submission Time
Task C - Tak and Cards
User nasif2587
Language C++14 (GCC 5.4.1)
Score 300
Code Size 923 Byte
Status AC
Exec Time 93 ms
Memory 51072 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:33:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld",&n,&t);
                             ^
./Main.cpp:36:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&a[i]);
                            ^

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 100 / 100
Status
AC × 4
AC × 12
AC × 24
Set Name Test Cases
Sample example_01.txt, example_02.txt, example_03.txt, example_04.txt
Subtask1 example_01.txt, example_02.txt, example_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt
All example_01.txt, example_02.txt, example_03.txt, example_04.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt
Case Name Status Exec Time Memory
example_01.txt AC 76 ms 51072 KB
example_02.txt AC 76 ms 51072 KB
example_03.txt AC 75 ms 51072 KB
example_04.txt AC 86 ms 51072 KB
subtask1_01.txt AC 75 ms 51072 KB
subtask1_02.txt AC 85 ms 51072 KB
subtask1_03.txt AC 76 ms 51072 KB
subtask1_04.txt AC 76 ms 51072 KB
subtask1_05.txt AC 76 ms 51072 KB
subtask1_06.txt AC 86 ms 51072 KB
subtask1_07.txt AC 86 ms 51072 KB
subtask1_08.txt AC 87 ms 51072 KB
subtask1_09.txt AC 76 ms 51072 KB
subtask2_01.txt AC 93 ms 51072 KB
subtask2_02.txt AC 84 ms 51072 KB
subtask2_03.txt AC 82 ms 51072 KB
subtask2_04.txt AC 76 ms 51072 KB
subtask2_05.txt AC 75 ms 51072 KB
subtask2_06.txt AC 76 ms 51072 KB
subtask2_07.txt AC 87 ms 51072 KB
subtask2_08.txt AC 88 ms 51072 KB
subtask2_09.txt AC 79 ms 51072 KB
subtask2_10.txt AC 90 ms 51072 KB
subtask2_11.txt AC 91 ms 51072 KB