Submission #855622


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
int N, A;
int inp[55];
long long dp[55][2600][55];
int main()
{
	scanf("%d %d", &N, &A);
	for(int n=0; n<N; n++)
	{
		scanf("%d", &inp[n]);
	}
	long long ans=0;
	dp[0][inp[0]][1]=1;
	dp[0][0][0] = 1;
	for(int n=0; n<N; n++)
	{
		for(int a=0; a<2600; a++)
		{
			for(int i=0; i<=N; i++)
			{
				if(dp[n][a][i])
				{
					//printf("%d %d %d is %d\n", n, a, i, dp[n][a][i]);
					dp[n+1][a+inp[n+1]][i+1] += dp[n][a][i];
					dp[n+1][a][i] += dp[n][a][i];
				}
				if(n==N-1 && i!=0)
				{
					if(a/i==A && a%i==0)
					{
						ans+= dp[n][a][i];
					}
				}
			}
		}
	}
	printf("%lld\n", ans);
}

Submission Info

Submission Time
Task C - Tak and Cards
User beeshi
Language C++14 (GCC 5.4.1)
Score 300
Code Size 682 Byte
Status AC
Exec Time 70 ms
Memory 14976 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:8:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &A);
                        ^
./Main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &inp[n]);
                       ^

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 7 ms 256 KB
example_02.txt AC 6 ms 256 KB
example_03.txt AC 10 ms 384 KB
example_04.txt AC 37 ms 1152 KB
subtask1_01.txt AC 19 ms 2432 KB
subtask1_02.txt AC 18 ms 896 KB
subtask1_03.txt AC 18 ms 896 KB
subtask1_04.txt AC 18 ms 384 KB
subtask1_05.txt AC 18 ms 1024 KB
subtask1_06.txt AC 4 ms 256 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt AC 19 ms 2176 KB
subtask1_09.txt AC 18 ms 1664 KB
subtask2_01.txt AC 70 ms 14976 KB
subtask2_02.txt AC 69 ms 14208 KB
subtask2_03.txt AC 68 ms 14464 KB
subtask2_04.txt AC 61 ms 5760 KB
subtask2_05.txt AC 62 ms 5760 KB
subtask2_06.txt AC 58 ms 1024 KB
subtask2_07.txt AC 63 ms 8192 KB
subtask2_08.txt AC 40 ms 5888 KB
subtask2_09.txt AC 42 ms 7808 KB
subtask2_10.txt AC 55 ms 11392 KB
subtask2_11.txt AC 56 ms 10112 KB