Submission #1035128


Source Code Expand

Copy
N, A = map(int, input().split())
y = [int(i) - A for i in input().split()]
y = [0] + y
X = max(max(y) + A,A)
dp = []
for i in range(N+1):
	dp.append([])
	for j in range(2*N*X+1):
		if i == 0 and j == N*X:
			dp[i].append(1)
		elif i >= 1 and (j - y[i] < 0 or j - y[i] > 2*N*X):
			dp[i].append(dp[i-1][j])
		elif i >= 1 and 0 <= j - y[i] and j - y[i] <= 2*N*X:
			dp[i].append(dp[i-1][j]+dp[i-1][j-y[i]])
		else:
			dp[i].append(0)
print(dp[N][N*X]-1)

Submission Info

Submission Time
Task C - 高橋君とカード / Tak and Cards
User TAB
Language Python3 (3.4.3)
Score 300
Code Size 467 Byte
Status
Exec Time 324 ms
Memory 5740 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 example_01.txt, example_02.txt, example_03.txt, example_04.txt
Subtask1 200 / 200 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 100 / 100 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 22 ms 3064 KB
example_02.txt 22 ms 3064 KB
example_03.txt 24 ms 3064 KB
example_04.txt 30 ms 3064 KB
subtask1_01.txt 52 ms 3316 KB
subtask1_02.txt 53 ms 3316 KB
subtask1_03.txt 52 ms 3316 KB
subtask1_04.txt 51 ms 3316 KB
subtask1_05.txt 52 ms 3316 KB
subtask1_06.txt 22 ms 3064 KB
subtask1_07.txt 23 ms 3064 KB
subtask1_08.txt 50 ms 3316 KB
subtask1_09.txt 48 ms 3316 KB
subtask2_01.txt 298 ms 5612 KB
subtask2_02.txt 313 ms 5740 KB
subtask2_03.txt 305 ms 5484 KB
subtask2_04.txt 315 ms 5236 KB
subtask2_05.txt 313 ms 5236 KB
subtask2_06.txt 324 ms 5236 KB
subtask2_07.txt 313 ms 5492 KB
subtask2_08.txt 151 ms 4204 KB
subtask2_09.txt 154 ms 4204 KB
subtask2_10.txt 220 ms 4844 KB
subtask2_11.txt 240 ms 4972 KB