Submission #856572


Source Code Expand

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

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

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

    ll r1=0,r2=0;

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

    r2=solve(i+1,sum,m);

    return dp[i][sum]=r1+r2;
}

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

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

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

    for(k=t; k<=cumsum; k+=t)
    {

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

    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 0
Code Size 896 Byte
Status WA
Exec Time 276 ms
Memory 1280 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:32: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 0 / 200 0 / 100
Status
AC × 3
WA × 1
AC × 8
WA × 4
AC × 10
WA × 14
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 6 ms 1280 KB
example_02.txt AC 6 ms 1280 KB
example_03.txt WA 6 ms 1280 KB
example_04.txt AC 9 ms 1280 KB
subtask1_01.txt AC 8 ms 1280 KB
subtask1_02.txt AC 7 ms 1280 KB
subtask1_03.txt WA 84 ms 1280 KB
subtask1_04.txt AC 4 ms 256 KB
subtask1_05.txt AC 7 ms 1280 KB
subtask1_06.txt AC 6 ms 1280 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt WA 8 ms 1280 KB
subtask1_09.txt WA 10 ms 1280 KB
subtask2_01.txt WA 28 ms 1280 KB
subtask2_02.txt WA 20 ms 1280 KB
subtask2_03.txt WA 27 ms 1280 KB
subtask2_04.txt AC 11 ms 1280 KB
subtask2_05.txt WA 276 ms 1280 KB
subtask2_06.txt WA 6 ms 1280 KB
subtask2_07.txt WA 16 ms 1280 KB
subtask2_08.txt WA 9 ms 1280 KB
subtask2_09.txt WA 10 ms 1280 KB
subtask2_10.txt WA 46 ms 1280 KB
subtask2_11.txt WA 22 ms 1280 KB