Submission #923099


Source Code Expand

Copy
N, A = map(int, input().split())
d = [x-A for x in list(map(int, input().split()))]
n = d.count(0)
d = [x for x in d if x != 0]
d.sort()
if not d:
	print(2**n - 1)
else:
	stack = []
	stack.append([0,0])
	stack.append([0,d[0]])
	ans = 0
	while stack:
		(pos, s) = stack.pop()

		if s == 0 and pos == len(d) - 1:
			ans += 1
		elif pos < len(d) - 1 and s <= 0:
			stack.append([pos+1,s])
			stack.append([pos+1,s + d[pos+1]])
	ans = ans * 2 ** n -1
	print(ans)

Submission Info

Submission Time
Task C - 高橋君とカード / Tak and Cards
User TAB
Language Python3 (3.4.3)
Score 200
Code Size 479 Byte
Status

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 0 / 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 23 ms 3064 KB
example_02.txt 23 ms 3064 KB
example_03.txt 24 ms 3064 KB
example_04.txt 23 ms 3064 KB
subtask1_01.txt 48 ms 3188 KB
subtask1_02.txt 24 ms 3064 KB
subtask1_03.txt 24 ms 3064 KB
subtask1_04.txt 93 ms 3188 KB
subtask1_05.txt 84 ms 3188 KB
subtask1_06.txt 23 ms 3064 KB
subtask1_07.txt 23 ms 3064 KB
subtask1_08.txt 89 ms 3188 KB
subtask1_09.txt 24 ms 3064 KB
subtask2_01.txt
subtask2_02.txt
subtask2_03.txt
subtask2_04.txt 23 ms 3064 KB
subtask2_05.txt 23 ms 3064 KB
subtask2_06.txt
subtask2_07.txt
subtask2_08.txt
subtask2_09.txt
subtask2_10.txt 36 ms 3064 KB
subtask2_11.txt