Submission #855187


Source Code Expand

Copy
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int n;
int A[55];

LL dp[55][55 * 55];
LL M;
int main()
{
	scanf("%d", &n);
	scanf("%lld", &M);
	for (int i = 1; i <= n; i++) scanf("%d", &A[i]);

	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int k = i - 1; k >= 0; k--) {
			for (int j = 0; j <= 50 * 50; j++) {
				if (dp[k][j]) {
					dp[k+1][j + A[i]] += dp[k][j];
				}
			}
		}
	}

	LL ans = 0;
		for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= 50 * 50; j++) {
			if (j == i * M)
				ans += dp[i][j];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Submission Info

Submission Time
Task C - Tak and Cards
User dragoon
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1662 Byte
Status AC
Exec Time 10 ms
Memory 768 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:54:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
./Main.cpp:55:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &M);
                   ^
./Main.cpp:56:49: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= n; i++) scanf("%d", &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 4 ms 256 KB
example_02.txt AC 4 ms 256 KB
example_03.txt AC 4 ms 256 KB
example_04.txt AC 6 ms 384 KB
subtask1_01.txt AC 4 ms 384 KB
subtask1_02.txt AC 5 ms 256 KB
subtask1_03.txt AC 5 ms 256 KB
subtask1_04.txt AC 5 ms 256 KB
subtask1_05.txt AC 4 ms 384 KB
subtask1_06.txt AC 4 ms 256 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt AC 5 ms 384 KB
subtask1_09.txt AC 4 ms 384 KB
subtask2_01.txt AC 10 ms 640 KB
subtask2_02.txt AC 10 ms 640 KB
subtask2_03.txt AC 9 ms 640 KB
subtask2_04.txt AC 9 ms 384 KB
subtask2_05.txt AC 9 ms 512 KB
subtask2_06.txt AC 9 ms 384 KB
subtask2_07.txt AC 10 ms 768 KB
subtask2_08.txt AC 7 ms 512 KB
subtask2_09.txt AC 6 ms 512 KB
subtask2_10.txt AC 8 ms 512 KB
subtask2_11.txt AC 8 ms 512 KB