Submission #860835


Source Code Expand

Copy
N, A = map(int, input().split())
x = list(map(int, input().split()))
y = [n - A for n in x]
p = [k for k in y if k > 0]
n = [k for k in y if k < 0]
z = y.count(0)
a = 2**z - 1

def c(n):
	i = n
	a = 0
	b = 0
	while i != 0:
		a += (i%2)*10**b
		b += 1
		i = int(i/2)
	return(a)

s = []
t = []
for i in range(1,2**len(p)):
	j = str(c(i))
	if len(j) < len(p):
		j = "0"*(len(p) - len(j)) + j
	s.append(j)

for i in range(1,2**len(n)):
	j = str(c(i))
	if len(j) < len(n):
		j = "0"*(len(n) - len(j)) + j
	t.append(j)

e = 0
for i in s:
	c = 0
	for u, j in enumerate(i):
		if j == "1":
			c += p[u]
	for k in t:
		d = c
		for m, l in enumerate(k):
			if l == "1":
				d += n[m]
		if d == 0:
			e += 1
a = a + e*(a+1)
print(a)

Submission Info

Submission Time
Task C - 高橋君とカード / Tak and Cards
User TAB
Language Python3 (3.4.3)
Score 200
Code Size 768 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 38 ms 3188 KB
example_02.txt 38 ms 3188 KB
example_03.txt 38 ms 3192 KB
example_04.txt 39 ms 3188 KB
subtask1_01.txt 118 ms 3188 KB
subtask1_02.txt 39 ms 3188 KB
subtask1_03.txt 1475 ms 8368 KB
subtask1_04.txt 1132 ms 8368 KB
subtask1_05.txt 205 ms 3192 KB
subtask1_06.txt 40 ms 3188 KB
subtask1_07.txt 37 ms 3188 KB
subtask1_08.txt 182 ms 3188 KB
subtask1_09.txt 203 ms 3572 KB
subtask2_01.txt
subtask2_02.txt
subtask2_03.txt
subtask2_04.txt 40 ms 3188 KB
subtask2_05.txt
subtask2_06.txt
subtask2_07.txt
subtask2_08.txt
subtask2_09.txt
subtask2_10.txt
subtask2_11.txt