Submission #855312


Source Code Expand

Copy
#include <bits/stdc++.h>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define REV(i, b, a) for(int i = b; i >= a; i--)
#define show(a) cout << #a << " = " << a << endl
#define mp make_pair
#define pb push_back
#define mset(v, a) memset(v, a, sizeof(v))
#define printv(v, n) for(int CONTADOR = 0; CONTADOR < n; CONTADOR++){ cout << v[CONTADOR] << " ";} cout << endl;
#define printm(mat, n, m) for(int OUTROCONTADOR = 0; OUTROCONTADOR < n; OUTROCONTADOR++) printv(mat[OUTROCONTADOR], m);
#define int long long
using namespace std;
inline string tostr(int a){stringstream ss; ss<<a; return ss.str();}
int n, a;
int v[100];
int dp[100][255][50];
int solve(int k, int num, int den){
	if(k >= n) {
		if(den != 0) return num/double(den) == a;
		return 0;
	}
	if(dp[k][num][den] >= 0) return dp[k][num][den];
	int ans = 0;
	ans += solve(k+1, num+v[k], den+1);
	ans += solve(k+1, num, den);
	return dp[k][num][den] = ans;
}

main(){

	while(cin >> n >> a){
		mset(dp, -1);
		REP(i, 0, n) cin >> v[i];
		cout << solve(0, 0, 0) << endl;
	}
	
	return 0;
}

Submission Info

Submission Time
Task C - Tak and Cards
User andre
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1084 Byte
Status WA
Exec Time 28 ms
Memory 10368 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 0 / 100
Status
AC × 4
AC × 12
AC × 19
WA × 5
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 17 ms 10240 KB
example_02.txt AC 17 ms 10240 KB
example_03.txt AC 17 ms 10240 KB
example_04.txt AC 17 ms 10240 KB
subtask1_01.txt AC 17 ms 10240 KB
subtask1_02.txt AC 17 ms 10240 KB
subtask1_03.txt AC 17 ms 10240 KB
subtask1_04.txt AC 20 ms 10240 KB
subtask1_05.txt AC 28 ms 10368 KB
subtask1_06.txt AC 17 ms 10240 KB
subtask1_07.txt AC 17 ms 10240 KB
subtask1_08.txt AC 18 ms 10240 KB
subtask1_09.txt AC 18 ms 10240 KB
subtask2_01.txt WA 25 ms 10240 KB
subtask2_02.txt WA 23 ms 10240 KB
subtask2_03.txt WA 23 ms 10240 KB
subtask2_04.txt AC 18 ms 10240 KB
subtask2_05.txt AC 17 ms 10240 KB
subtask2_06.txt AC 20 ms 10240 KB
subtask2_07.txt AC 18 ms 10240 KB
subtask2_08.txt AC 22 ms 10240 KB
subtask2_09.txt AC 21 ms 10240 KB
subtask2_10.txt WA 21 ms 10240 KB
subtask2_11.txt WA 23 ms 10240 KB