Submission #855478


Source Code Expand

Copy
//It’s never too late to become what you might have been....
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define inf 1000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 100001

ll dp[2][51][2501],sum[51],a[51];
int main()
{
	boost1;boost2;
	ll i,j,n,A,ans=0,k;	
	cin>>n>>A;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}	
	dp[0][0][0]=1;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=i;j++)
		{
			for(k=0;k<=sum[i];k++)
			{
				dp[(i%2)][j][k]=dp[(i-1)%2][j][k];
				if(k-a[i]>=0 && j!=0)
				dp[(i%2)][j][k]+=dp[(i-1)%2][j-1][k-a[i]];
			}
		}
	}
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=sum[n];j++)
		{
			if(i==0)
			continue;
			if(j%i==0 && j/i==A)
			ans+=dp[(n%2)][i][j];
		}
	}
	cout<<ans;
	return 0;
}

Submission Info

Submission Time
Task C - Tak and Cards
User shubhamgoyal__
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1053 Byte
Status AC
Exec Time 15 ms
Memory 2176 KB

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 4 ms 256 KB
example_02.txt AC 4 ms 256 KB
example_03.txt AC 4 ms 384 KB
example_04.txt AC 4 ms 512 KB
subtask1_01.txt AC 5 ms 512 KB
subtask1_02.txt AC 5 ms 640 KB
subtask1_03.txt AC 5 ms 640 KB
subtask1_04.txt AC 4 ms 384 KB
subtask1_05.txt AC 4 ms 512 KB
subtask1_06.txt AC 4 ms 256 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt AC 4 ms 512 KB
subtask1_09.txt AC 5 ms 512 KB
subtask2_01.txt AC 10 ms 1664 KB
subtask2_02.txt AC 10 ms 1664 KB
subtask2_03.txt AC 10 ms 1536 KB
subtask2_04.txt AC 15 ms 2176 KB
subtask2_05.txt AC 15 ms 2176 KB
subtask2_06.txt AC 5 ms 640 KB
subtask2_07.txt AC 10 ms 1664 KB
subtask2_08.txt AC 6 ms 896 KB
subtask2_09.txt AC 7 ms 1024 KB
subtask2_10.txt AC 8 ms 1280 KB
subtask2_11.txt AC 8 ms 1280 KB