s_id string | p_id string | u_id string | date string | language string | original_language string | filename_ext string | status string | cpu_time string | memory string | code_size string | code string | error string | stdout string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s621667732 | p02271 | u796784914 | 1497085973 | Python | Python | py | Runtime Error | 0 | 0 | 922 | class MyClass():
def main(self):
self.n = input()
self.A = map(int,raw_input().split())
self.q = input()
self.M = map(int,raw_input().split())
W = map(self.solve,self.M)
for w in W:
print w
def solve(self,m):
w = self.rec(m,self.A)
if w:
return "yes"
else:
return "no"
def rec(self,m,A):
if len(A) == 1:
r1 = False
else:
r1 = self.rec(m,A[1:])
m_new = m - A[0]
if m_new < 0:
r2 = False
elif m_new == 0:
r2 = True
elif m_new < min(A[1:]) or len(A) == 1:
r2 = False
else:
r2 = self.rec(m_new,A[1:])
if r1 or r2:
return True
else:
return False
if __name__ == "__main__":
MC = MyClass()
MC.main() | File "/tmp/tmp8_4xs8b0/tmpzl5dntvn.py", line 10
print w
^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s387658587 | p02271 | u796784914 | 1497091177 | Python | Python | py | Runtime Error | 0 | 0 | 435 | from collections import deque
import numpy as np
def main():
n = input()
A = deque(map(int,raw_input().split()))
q = input()
M = map(int,raw_input().split())
a = np.array([0])
p = rec(a,A)
for m in M:
print "yes" if m in p else "no"
def rec(a,A):
if len(A) == 0:
return a
else:
a = np.append(a,a+A.popleft())
return rec(a,A)
if __name__ == "__main__":
main() | File "/tmp/tmpgn0dl0wc/tmps6kr7tnr.py", line 14
print "yes" if m in p else "no"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s857218090 | p02271 | u796784914 | 1497091308 | Python | Python | py | Runtime Error | 0 | 0 | 435 | from collections import deque
import numpy as np
def main():
n = input()
A = deque(map(int,raw_input().split()))
q = input()
M = map(int,raw_input().split())
a = np.array([0])
p = rec(a,A)
for m in M:
print "yes" if m in p else "no"
def rec(a,A):
if len(A) == 0:
return a
else:
a = np.append(a,a+A.popleft())
return rec(a,A)
if __name__ == "__main__":
main() | File "/tmp/tmphhtl9mht/tmpuhpv6wsj.py", line 14
print "yes" if m in p else "no"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s898047884 | p02271 | u264972437 | 1501153561 | Python | Python3 | py | Runtime Error | 0 | 0 | 412 | def solve(i,m):
if m == 0:
return True
if i >= n:
return False
res = solve(i+1,m) or solve(i+1,m-A[i])
return res
n = int(input())
A = input()
A = [int(s) for s in A.split()]
q = int(input())
m = input()
m = [int(s) for s in m.split()]
ans = ''
s = sum(A)
for mm in m:
if s < mm:
ans += 'no'
else:
ans += solve(0,mm)
#ans = [{True:'yes',False:'no'}[solve(0,mm)] for mm in m]
print('\n'.join(ans)) | Traceback (most recent call last):
File "/tmp/tmpgifals17/tmpi8xks8g6.py", line 9, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s957953192 | p02271 | u491916705 | 1502243462 | Python | Python | py | Runtime Error | 0 | 0 | 586 | wimport numpy as np
n = int(raw_input())
data = map(int, raw_input().split())
m = int(raw_input())
test = map(int, raw_input().split())
# def solve(i,left):
# if left == 0:
# return True
# elif i >= n:
# return False
# return solve(i+1, left) or solve(i+1, left - data[i])
# for j in range(m):
# if solve(0, test[j]):
# print 'yes'
# else:
# print 'no'
a = [0]
for i in range(n):
a = a + [a[j] + data[i] for j in range(len(a))]
for i in range(m):
if test[i] in a:
print 'yes'
else:
print 'no'
| File "/tmp/tmphb4e818c/tmpyvvpe0r7.py", line 1
wimport numpy as np
^^^^^
SyntaxError: invalid syntax
| |
s254645838 | p02271 | u491916705 | 1502243536 | Python | Python | py | Runtime Error | 0 | 0 | 586 | wimport numpy as np
n = int(raw_input())
data = map(int, raw_input().split())
m = int(raw_input())
test = map(int, raw_input().split())
# def solve(i,left):
# if left == 0:
# return True
# elif i >= n:
# return False
# return solve(i+1, left) or solve(i+1, left - data[i])
# for j in range(m):
# if solve(0, test[j]):
# print 'yes'
# else:
# print 'no'
a = [0]
for i in range(n):
a = a + [a[j] + data[i] for j in range(len(a))]
for i in range(m):
if test[i] in a:
print 'yes'
else:
print 'no'
| File "/tmp/tmp5wek_854/tmponlgbn9x.py", line 1
wimport numpy as np
^^^^^
SyntaxError: invalid syntax
| |
s552551361 | p02271 | u285015144 | 1503632069 | Python | Python3 | py | Runtime Error | 0 | 0 | 442 | import numpy as np
n = input()
n = int(n)
a = input()
a = a.split()
a = [int(x) for x in a]
q = input()
q = int(q)
ms = input()
ms = ms.split()
ms = [int(x) for x in ms]
np.sort(a)
a = np.array(a)
for m in ms:
if m > a[-1]:
print("no")
elif a.any()==m:
print("yes")
else:
a_new = a[a < m]
print(a_new)
select = []
length = len(a_new)
selects = np.zeros(2**length, length) | Traceback (most recent call last):
File "/tmp/tmprsfbbu17/tmptvp3tcj6.py", line 3, in <module>
n = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s165002846 | p02271 | u153665391 | 1506082459 | Python | Python3 | py | Runtime Error | 0 | 0 | 526 | def exhaustive_search(start, Sum, answer):
for i in range(start, n):
Sum = Sum + A[i]
if Sum == answer:
return True
elif Sum > answer:
Sum = Sum - A[i]
next
else:
r = exhaustive_search(i+1, Sum, answer)
if r == True:
return True
else:
Sum = Sum - A[i]
return False
for i in M:
r = exhaustive_search(0, 0, i)
if r == True:
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmpiz2z6gjs/tmpvjqy9jfn.py", line 18, in <module>
for i in M:
^
NameError: name 'M' is not defined
| |
s342391935 | p02271 | u153665391 | 1506082525 | Python | Python3 | py | Runtime Error | 0 | 0 | 526 | def exhaustive_search(start, Sum, answer):
for i in range(start, n):
Sum = Sum + A[i]
if Sum == answer:
return True
elif Sum > answer:
Sum = Sum - A[i]
next
else:
r = exhaustive_search(i+1, Sum, answer)
if r == True:
return True
else:
Sum = Sum - A[i]
return False
for i in M:
r = exhaustive_search(0, 0, i)
if r == True:
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmpepxl4urf/tmp_a0l435c.py", line 18, in <module>
for i in M:
^
NameError: name 'M' is not defined
| |
s522352650 | p02271 | u153665391 | 1506082547 | Python | Python3 | py | Runtime Error | 0 | 0 | 526 | def exhaustive_search(start, Sum, answer):
for i in range(start, n):
Sum = Sum + A[i]
if Sum == answer:
return True
elif Sum > answer:
Sum = Sum - A[i]
next
else:
r = exhaustive_search(i+1, Sum, answer)
if r == True:
return True
else:
Sum = Sum - A[i]
return False
for i in M:
r = exhaustive_search(0, 0, i)
if r == True:
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmpgprpy_hd/tmpfmukiatv.py", line 18, in <module>
for i in M:
^
NameError: name 'M' is not defined
| |
s501163060 | p02271 | u153665391 | 1506082686 | Python | Python3 | py | Runtime Error | 0 | 0 | 536 | def exhaustive_search(start, Sum, answer):
for i in range(start, n):
Sum = Sum + A[i]
if Sum == answer:
return True
elif Sum > answer:
Sum = Sum - A[i]
next
else:
r = exhaustive_search(i+1, Sum, answer)
if r == True:
return True
else:
Sum = Sum - A[i]
return False
for i in M:
r = exhaustive_search(0, 0, i)
if r == True:
print('yes')
else:
print('no')
return 0 | File "/tmp/tmpp9s3g1e8/tmp9oh_c_p7.py", line 25
return 0
^^^^^^^^
SyntaxError: 'return' outside function
| |
s098276643 | p02271 | u153665391 | 1506083060 | Python | Python3 | py | Runtime Error | 0 | 0 | 536 | def exhaustive_search(start, Sum, answer):
for i in range(start, n):
Sum = Sum + A[i]
if Sum == answer:
return True
elif Sum > answer:
Sum = Sum - A[i]
next
else:
r = exhaustive_search(i+1, Sum, answer)
if r == True:
return True
else:
Sum = Sum - A[i]
return False
for i in M:
r = exhaustive_search(0, 0, i)
if r == True:
print('yes')
else:
print('no')
print('') | Traceback (most recent call last):
File "/tmp/tmpz98k5g03/tmp7okycm9p.py", line 18, in <module>
for i in M:
^
NameError: name 'M' is not defined
| |
s799089717 | p02271 | u153665391 | 1506083065 | Python | Python3 | py | Runtime Error | 0 | 0 | 537 | def exhaustive_search(start, Sum, answer):
for i in range(start, n):
Sum = Sum + A[i]
if Sum == answer:
return True
elif Sum > answer:
Sum = Sum - A[i]
next
else:
r = exhaustive_search(i+1, Sum, answer)
if r == True:
return True
else:
Sum = Sum - A[i]
return False
for i in M:
r = exhaustive_search(0, 0, i)
if r == True:
print('yes')
else:
print('no')
print(' ') | Traceback (most recent call last):
File "/tmp/tmpmt3td93m/tmpc_saiuuj.py", line 18, in <module>
for i in M:
^
NameError: name 'M' is not defined
| |
s621555855 | p02271 | u153665391 | 1506083078 | Python | Python3 | py | Runtime Error | 0 | 0 | 537 | def exhaustive_search(start, Sum, answer):
for i in range(start, n):
Sum = Sum + A[i]
if Sum == answer:
return True
elif Sum > answer:
Sum = Sum - A[i]
next
else:
r = exhaustive_search(i+1, Sum, answer)
if r == True:
return True
else:
Sum = Sum - A[i]
return False
for i in M:
r = exhaustive_search(0, 0, i)
if r == True:
print('yes')
else:
print('no')
print(?\n) | File "/tmp/tmph36il80d/tmpby_94nmi.py", line 24
print(?\n)
^
SyntaxError: invalid syntax
| |
s414079347 | p02271 | u798803522 | 1509464229 | Python | Python3 | py | Runtime Error | 30 | 7704 | 435 | a_len = int(input())
a_ar = sorted([int(n) for n in input().split(" ")])
b_len = int(input())
b_ar = [int(n) for n in input().split(" ")]
max_b = max(b_ar)
dp = [0 for n in range(max_b + 1)]
for a in a_ar:
new_dp = dp[:]
new_dp[a] = 1
for i,d in enumerate(dp):
if d and i + a <= max_b + 1:
new_dp[i + a] = 1
dp = new_dp
for b in b_ar:
if dp[b]:
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmpg3shwkir/tmpwixh59od.py", line 1, in <module>
a_len = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s425685471 | p02271 | u626266743 | 1510157445 | Python | Python3 | py | Runtime Error | 0 | 0 | 345 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for i in mi:
if solve(0, m):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmpz22kr7f1/tmpd48r4yp8.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s819000500 | p02271 | u626266743 | 1510157632 | Python | Python3 | py | Runtime Error | 0 | 0 | 345 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for i in q:
if solve(0, mi):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmpb1ip3anz/tmpbhsk4gj4.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s020935014 | p02271 | u626266743 | 1510157724 | Python | Python3 | py | Runtime Error | 0 | 0 | 352 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for i in range(q):
if solve(0, mi):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmpqpyhkexw/tmpx9riqni3.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s765337283 | p02271 | u626266743 | 1510157844 | Python | Python3 | py | Runtime Error | 0 | 0 | 357 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = set(map(int, input().split()))
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for i in range(q):
if solve(0, mi):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmp46hrggva/tmpo0eugomn.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s404925938 | p02271 | u626266743 | 1510660603 | Python | Python3 | py | Runtime Error | 0 | 0 | 352 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for i in range(q):
if solve(0, mi):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmpddhswo7x/tmpbn24dsoz.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s536529731 | p02271 | u626266743 | 1510660660 | Python | Python3 | py | Runtime Error | 0 | 0 | 352 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for i in range(q):
if solve(0, mi):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmpdihblmr3/tmp92bq_zov.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s154218089 | p02271 | u626266743 | 1510660890 | Python | Python3 | py | Runtime Error | 0 | 0 | 352 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for j in range(q):
if solve(0, mi):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmpsbzsmxj2/tmpq8_n076w.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s218803579 | p02271 | u626266743 | 1510661456 | Python | Python3 | py | Runtime Error | 0 | 0 | 352 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for j in range(q):
if solve(0, mi):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmpl30xwn_b/tmpet4e4d95.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s832966327 | p02271 | u626266743 | 1510661857 | Python | Python3 | py | Runtime Error | 0 | 0 | 371 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
S = {}
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for j in range(1, q + 1):
if solve(0, mi):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmpn6pdap1v/tmpo5kgdgnz.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s068337859 | p02271 | u626266743 | 1510661883 | Python | Python3 | py | Runtime Error | 0 | 0 | 364 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
S = {}
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for j in range(q):
if solve(0, mi):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmpb7cmdnid/tmpl6qvtylu.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s023571336 | p02271 | u626266743 | 1510662057 | Python | Python3 | py | Runtime Error | 0 | 0 | 429 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
tmp = {}
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
if (i,m) in tmp:
return tmp[(i,m)]
res = solve(i + 1, m) or solve(i + 1, m - A[i])
tmp[(i,m)] = res
return res
for j in range(q):
if solve(0, mi):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmpg96u5_lz/tmpg3f57e5f.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s419861329 | p02271 | u626266743 | 1510662077 | Python | Python3 | py | Runtime Error | 0 | 0 | 421 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
t = {}
def solve(i, m):
if (m == 0):
return True
if (i >= n):
return False
if (i,m) in t:
return t[(i,m)]
res = solve(i + 1, m) or solve(i + 1, m - A[i])
t[(i,m)] = res
return res
for j in range(q):
if solve(0, mi):
print("yes")
else:
print("no") | Traceback (most recent call last):
File "/tmp/tmp9gj4r6iv/tmp1s3kqy01.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s512133231 | p02271 | u424457654 | 1510672838 | Python | Python3 | py | Runtime Error | 0 | 0 | 365 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
def solve(i, m):
if m == 0:
return True
if i >= n :
return False
res = solve(i + 1, m) or solve(i + 1, m - a[i])
return res
for tmp_m in m:
if sum(a) < tmp_m:
print('no')
elif solve(0, tmp_m):
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmpv51yi57b/tmpqhw0i1k7.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s819040341 | p02271 | u845643816 | 1510712172 | Python | Python3 | py | Runtime Error | 0 | 0 | 363 | n = int(sys.stdin.readline())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
def solve(i, m):
if m == 0:
return True
elif i >= n:
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for m in M:
if solve(0, m):
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmpufw2vvbk/tmp3cv6ybbj.py", line 1, in <module>
n = int(sys.stdin.readline())
^^^
NameError: name 'sys' is not defined
| |
s239572457 | p02271 | u845643816 | 1510713097 | Python | Python3 | py | Runtime Error | 0 | 0 | 470 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
table = [[0]*max(M)]*n
def solve(i, m):
if m == 0:
return True
elif i >= n:
return False
elif table[i][m] != 0:
return table[i][m]
else:
res = solve(i + 1, m) or solve(i + 1, m - A[i])
table[i][m] = res
return res
for m in M:
if solve(0, m):
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmp751ynhn7/tmpc41sen7p.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s569322393 | p02271 | u845643816 | 1510713314 | Python | Python3 | py | Runtime Error | 0 | 0 | 502 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
table = [[0 for i in range(max(M))] for j in range(n)]
def solve(i, m):
if m == 0:
return True
elif i >= n:
return False
elif table[i][m] != 0:
return table[i][m]
else:
res = solve(i + 1, m) or solve(i + 1, m - A[i])
table[i][m] = res
return res
for m in M:
if solve(0, m):
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmp1e7t3tbv/tmpwpf67tsy.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s569567002 | p02271 | u845643816 | 1510713395 | Python | Python3 | py | Runtime Error | 0 | 0 | 502 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
table = [[0 for i in range(n)] for j in range(max(M))]
def solve(i, m):
if m == 0:
return True
elif i >= n:
return False
elif table[i][m] != 0:
return table[i][m]
else:
res = solve(i + 1, m) or solve(i + 1, m - A[i])
table[i][m] = res
return res
for m in M:
if solve(0, m):
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmp4p1di75t/tmpyq8_ocgs.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s360084446 | p02271 | u845643816 | 1510713578 | Python | Python3 | py | Runtime Error | 0 | 0 | 504 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
table = [[0 for i in range(n)] for j in range(max(M)+1)]
def solve(i, m):
if m == 0:
return True
elif i >= n:
return False
elif table[i][m] != 0:
return table[i][m]
else:
res = solve(i + 1, m) or solve(i + 1, m - A[i])
table[i][m] = res
return res
for m in M:
if solve(0, m):
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmp8z7dut2h/tmpopx291sh.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s029874904 | p02271 | u845643816 | 1510713711 | Python | Python3 | py | Runtime Error | 30 | 7668 | 504 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
table = [[0 for i in range(max(M)+1)] for j in range(n)]
def solve(i, m):
if m == 0:
return True
elif i >= n:
return False
elif table[i][m] != 0:
return table[i][m]
else:
res = solve(i + 1, m) or solve(i + 1, m - A[i])
table[i][m] = res
return res
for m in M:
if solve(0, m):
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmpsvnic7v_/tmpzro9ctph.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s276587969 | p02271 | u548155360 | 1512300861 | Python | Python3 | py | Runtime Error | 13600 | 5616 | 659 | # coding=utf-8
def is_made_sum(array: list, target: int) -> bool:
if target == 0:
return True
elif target < 0:
return False
elif not array:
return False
else:
choice = array[0]
result1 = is_made_sum(array[1:], target)
result2 = is_made_sum(array[1:], target - choice)
return result1 | result2
if __name__ == '__main__':
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
for i in range(q):
answer = is_made_sum(A, M[i])
if answer:
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmp5n3wi__4/tmph2qhvk42.py", line 17, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s973037946 | p02271 | u548155360 | 1512301436 | Python | Python3 | py | Runtime Error | 13400 | 5616 | 659 | # coding=utf-8
def is_made_sum(array: list, target: int) -> bool:
if target == 0:
return True
elif target < 0:
return False
elif not array:
return False
else:
choice = array[0]
result1 = is_made_sum(array[1:], target)
result2 = is_made_sum(array[1:], target - choice)
return result1 | result2
if __name__ == '__main__':
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
for i in range(q):
answer = is_made_sum(A, M[i])
if answer:
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmp0bqb0yr0/tmpzy3ac1my.py", line 17, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s673882612 | p02271 | u548155360 | 1512301734 | Python | Python3 | py | Runtime Error | 13430 | 5616 | 660 | # coding=utf-8
def is_made_sum(array: list, target: int) -> bool:
if target == 0:
return True
elif target < 0:
return False
elif not array:
return False
else:
choice = array[0]
result1 = is_made_sum(array[1:], target)
result2 = is_made_sum(array[1:], target - choice)
return result1 or result2
if __name__ == '__main__':
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
for i in range(q):
answer = is_made_sum(A, M[i])
if answer:
print('yes')
else:
print('no') | Traceback (most recent call last):
File "/tmp/tmpvboo8iyu/tmp3dpsgne9.py", line 17, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s213990783 | p02271 | u539789745 | 1513179513 | Python | Python3 | py | Runtime Error | 16840 | 5624 | 694 | def main():
"""
2^20 = 1,048,576
q = 200
200,000,000
limit 5s ???????????????OK
"""
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = map(int, input().split())
for m in M:
if solve(m, A, n):
print("yes")
else:
print("no")
def solve(m, A, n):
for b in f(n):
s = sum(a * bit for a, bit in zip(A, b))
if m == s:
return True
return False
def f(n):
for i in range(2 ** n):
# 0/1???n??????????????????bit????????¨
# 0b ?????????
bit = bin(i)[2:]
yield map(int, bit.zfill(n))
if __name__ == '__main__':
main() | Traceback (most recent call last):
File "/tmp/tmpl0et_pes/tmpc3e7qrle.py", line 37, in <module>
main()
File "/tmp/tmpl0et_pes/tmpc3e7qrle.py", line 8, in main
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s453867818 | p02271 | u539789745 | 1513180972 | Python | Python3 | py | Runtime Error | 5530 | 5680 | 780 | from itertools import product
def main():
"""
2^20 = 1,048,576
q = 200
200,000,000
limit 5s ???????????????OK
"""
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = map(int, input().split())
for m in M:
if m == 0 or solve(m, A, n):
print("yes")
else:
print("no")
def solve(m, A, n):
# for b in f1(n):
for b in product([0, 1], repeat=n):
s = sum(a * bit for a, bit in zip(A, b))
if m == s:
return True
return False
def f1(n):
for i in range(2 ** n):
# 0/1???n??????????????????bit????????¨
# 0b ?????????
bit = bin(i)[2:]
yield map(int, bit.zfill(n))
if __name__ == '__main__':
main() | Traceback (most recent call last):
File "/tmp/tmp9f9v4dtz/tmptemoeb7f.py", line 41, in <module>
main()
File "/tmp/tmp9f9v4dtz/tmptemoeb7f.py", line 11, in main
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s978740013 | p02271 | u530663965 | 1514077195 | Python | Python3 | py | Runtime Error | 6680 | 5616 | 551 |
def main():
base = get_input()
li = get_input()
base.sort()
for l in li:
if check_list(base, 0, l, len(base)):
print('yes')
else:
print('no')
def check_list(base, idx, key, length):
if key == 0:
return True
elif idx >= length:
return False
res = check_list(base, idx + 1, key, length) or check_list(base, idx + 1, key - base[idx], length)
return res
def get_input():
_ = int(input())
li = [int(x) for x in input().split(' ')]
return li
main() | Traceback (most recent call last):
File "/tmp/tmpis_91lb7/tmp680bfawm.py", line 30, in <module>
main()
File "/tmp/tmpis_91lb7/tmp680bfawm.py", line 3, in main
base = get_input()
^^^^^^^^^^^
File "/tmp/tmpis_91lb7/tmp680bfawm.py", line 25, in get_input
_ = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s717277503 | p02271 | u530663965 | 1514077237 | Python | Python3 | py | Runtime Error | 6720 | 5616 | 593 | import sys
sys.setrecursionlimit(10000)
def main():
base = get_input()
li = get_input()
base.sort()
for l in li:
if check_list(base, 0, l, len(base)):
print('yes')
else:
print('no')
def check_list(base, idx, key, length):
if key == 0:
return True
elif idx >= length:
return False
res = check_list(base, idx + 1, key, length) or check_list(base, idx + 1, key - base[idx], length)
return res
def get_input():
_ = int(input())
li = [int(x) for x in input().split(' ')]
return li
main() | Traceback (most recent call last):
File "/tmp/tmppsj9j2k_/tmpgxju8kcv.py", line 34, in <module>
main()
File "/tmp/tmppsj9j2k_/tmpgxju8kcv.py", line 7, in main
base = get_input()
^^^^^^^^^^^
File "/tmp/tmppsj9j2k_/tmpgxju8kcv.py", line 29, in get_input
_ = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s975481521 | p02271 | u585035894 | 1514625757 | Python | Python3 | py | Runtime Error | 9670 | 5612 | 343 | input()
a = [int(i) for i in input().split()]
def solve(i, m):
if m == 0:
return True
if i >= len(a):
return False
return solve(i+1, m) or solve(i+1, m - a[i]) # m - a[i] ??§????????°???????????£???????????????????????????
input()
for i in input().split():
print('yes') if solve(0, int(i)) else print('no') | Traceback (most recent call last):
File "/tmp/tmpd80fv67g/tmp_9kdcfs0.py", line 1, in <module>
input()
EOFError: EOF when reading a line
| |
s289550475 | p02271 | u585035894 | 1514627734 | Python | Python3 | py | Runtime Error | 9750 | 5620 | 384 | import sys
sys.setrecursionlimit(10000)
input()
a = [int(i) for i in input().split()]
def solve(i, m):
if m == 0:
return True
if i >= len(a):
return False
return solve(i+1, m) or solve(i+1, m - a[i]) # m - a[i] ??§????????°???????????£???????????????????????????
input()
for i in input().split():
print('yes') if solve(0, int(i)) else print('no') | Traceback (most recent call last):
File "/tmp/tmpuzehdqoq/tmpr4trjp90.py", line 4, in <module>
input()
EOFError: EOF when reading a line
| |
s958612052 | p02271 | u426534722 | 1516717359 | Python | Python3 | py | Runtime Error | 5560 | 5656 | 353 | from itertools import combinations
n = int(input())
A = tuple(map(int, input().split()))
def solve(m):
if m in A:
return "yes"
for i in range(2, n + 1):
for C in combinations(A, i):
if sum(C) == m:
return "yes"
return "no"
q = int(input())
for m in map(int, input().split()):
print(solve(m))
| Traceback (most recent call last):
File "/tmp/tmpeezy2s_4/tmpu5t_m9e4.py", line 2, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s815348491 | p02271 | u426534722 | 1516718051 | Python | Python3 | py | Runtime Error | 2640 | 5652 | 414 | from itertools import combinations
n = int(input())
A = tuple(map(int, input().split()))
SET = set(A)
def solve(m):
if m in A:
return "yes"
for i in range(1, n):
for C in combinations(A, i):
sumC = sum(C)
if sumC < m and m - sumC in SET - set(C):
return "yes"
return "no"
q = int(input())
for m in map(int, input().split()):
print(solve(m))
| Traceback (most recent call last):
File "/tmp/tmpbmf6o6op/tmp3q8swtrx.py", line 2, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s821833052 | p02271 | u426534722 | 1516718495 | Python | Python3 | py | Runtime Error | 5640 | 15628 | 411 | from itertools import combinations
n = int(input())
A = tuple(map(int, input().split()))
SET = set(A)
def solve(m):
if m in A:
return "yes"
dp = [0]
for a in A:
q = []
for d in dp:
q.append(d)
q.append(d + a)
dp = q
if m in dp:
return "yes"
return "no"
q = int(input())
for m in map(int, input().split()):
print(solve(m))
| Traceback (most recent call last):
File "/tmp/tmpty0epb36/tmpw91jyv37.py", line 2, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s211551433 | p02271 | u662418022 | 1517046375 | Python | Python3 | py | Runtime Error | 8510 | 5620 | 489 | # -*- coding: utf-8 -*-
if __name__ == '__main__':
n = int(input())
A = [int(a) for a in input().split(" ")]
q = int(input())
M = [int(m) for m in input().split(" ")]
def solve(i, m):
if m == 0:
return True
if i >= n:
return False
res = solve(i+1, m) or solve(i+1, m-A[i])
return res
for m in M:
if solve(0, m)==True:
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmp0a9gjwag/tmp7hiqu87_.py", line 6, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s159316119 | p02271 | u662418022 | 1517046538 | Python | Python3 | py | Runtime Error | 7490 | 5616 | 489 | # -*- coding: utf-8 -*-
if __name__ == '__main__':
n = int(input())
A = [int(a) for a in input().split(" ")]
q = int(input())
M = [int(m) for m in input().split(" ")]
def solve(i, m):
if m == 0:
return True
if i >= n:
return False
res = solve(i+1, m) or solve(i+1, m-A[i])
return res
for m in M:
if solve(0, m)==True:
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmp5i8z9wm7/tmpt9sjb91r.py", line 6, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s626069506 | p02271 | u662418022 | 1517046699 | Python | Python3 | py | Runtime Error | 8030 | 5612 | 526 | # -*- coding: utf-8 -*-
if __name__ == '__main__':
n = int(input())
A = [int(a) for a in input().split(" ")]
q = int(input())
M = [int(m) for m in input().split(" ")]
def solve(i, m):
if m == 0:
return True
if i >= n:
return False
res = solve(i+1, m) or solve(i+1, m-A[i])
return res
ans = []
for m in M:
if solve(0, m)==True:
ans.append("yes")
else:
ans.append("no")
print("\n".join(ans))
| Traceback (most recent call last):
File "/tmp/tmp361q6x50/tmpvv_1egwo.py", line 6, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s634229506 | p02271 | u749243807 | 1517067731 | Python | Python3 | py | Runtime Error | 0 | 0 | 411 | A_count = int(input());
A = [int(n) for n in input().split()];
M_count = int(input());
M = [int(n) for n in input().split];
def solve(start, target):
if target == 0:
return True;
elif start >= n:
return False:
else:
return solve(start + 1, target) || solve(start + 1, target - A[start]);
for m in M:
if solve(0, m):
print("yes");
else:
print("no");
| File "/tmp/tmp231_pczm/tmpv69ux379.py", line 10
return False:
^
SyntaxError: invalid syntax
| |
s317360636 | p02271 | u749243807 | 1517067820 | Python | Python3 | py | Runtime Error | 7260 | 5616 | 419 | A_count = int(input());
A = [int(n) for n in input().split()];
M_count = int(input());
M = [int(n) for n in input().split()];
def solve(start, target):
if target == 0:
return True;
elif start >= A_count:
return False;
else:
return solve(start + 1, target) or solve(start + 1, target - A[start]);
for m in M:
if solve(0, m):
print("yes");
else:
print("no");
| Traceback (most recent call last):
File "/tmp/tmp3o7npzwv/tmp0ttg8cmf.py", line 1, in <module>
A_count = int(input());
^^^^^^^
EOFError: EOF when reading a line
| |
s560917979 | p02271 | u749243807 | 1517067962 | Python | Python3 | py | Runtime Error | 7580 | 5616 | 419 | A_count = int(input());
A = [int(n) for n in input().split()];
M_count = int(input());
M = [int(n) for n in input().split()];
def solve(start, target):
if target == 0:
return True;
elif start >= A_count:
return False;
else:
return solve(start + 1, target) or solve(start + 1, target - A[start]);
for m in M:
if solve(0, m):
print("yes");
else:
print("no");
| Traceback (most recent call last):
File "/tmp/tmpd5wwdogc/tmpesagaxt0.py", line 1, in <module>
A_count = int(input());
^^^^^^^
EOFError: EOF when reading a line
| |
s606427376 | p02271 | u749243807 | 1517069265 | Python | Python3 | py | Runtime Error | 0 | 0 | 725 | A_count = int(input());
A = [int(n) for n in input().split()];
M_count = int(input());
M = [int(n) for n in input().split()];
memo = [[None for i in range(2000)] for j in range(A_count)];
def solve(start, target):
if memo[start][target] is not None:
return memo[start][target];
if target == 0:
return True;
elif start >= A_count:
return False;
else:
result = solve(start + 1, target) or solve(start + 1, target - A[start]);
if result:
memo[start][target] = True;
return True;
else:
memo[start][target] = False;
return False;
for m in M:
if solve(0, m):
print("yes");
else:
print("no");
| Traceback (most recent call last):
File "/tmp/tmpm36m2t49/tmpapnhk2x5.py", line 1, in <module>
A_count = int(input());
^^^^^^^
EOFError: EOF when reading a line
| |
s472276972 | p02271 | u208157605 | 1518041252 | Python | Python3 | py | Runtime Error | 7450 | 5612 | 366 |
def solve(i, m):
if m == 0:
return True
elif i >= n:
return False
res = solve(i + 1, m) or solve(i + 1, m - arr[i])
return res
n = int(input())
arr = list(map(int, input().split()))
q = input()
requests = list(map(int, input().split()))
for req in requests:
if solve(0, req):
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmpkun7ip3a/tmptouycsxy.py", line 10, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s203170058 | p02271 | u177808190 | 1518186098 | Python | Python3 | py | Runtime Error | 8300 | 5616 | 394 | def exSearch(i, m, hoge):
if m == 0:
return True
if i >= len(hoge):
return False
res = exSearch(i+1, m, hoge) or exSearch(i+1, m-hoge[i], hoge)
return res
_ = int(input())
hoge = [int(x) for x in input().split()]
_ = int(input())
for val in (int(x) for x in input().split()):
if exSearch(0, val, hoge):
print ('yes')
else:
print ('no')
| Traceback (most recent call last):
File "/tmp/tmpe33bvmwl/tmp8ekas5by.py", line 9, in <module>
_ = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s906277575 | p02271 | u177808190 | 1518186142 | Python | Python3 | py | Runtime Error | 9030 | 5612 | 394 | def exSearch(i, m, hoge):
if m == 0:
return True
if i >= len(hoge):
return False
res = exSearch(i+1, m, hoge) or exSearch(i+1, m-hoge[i], hoge)
return res
_ = int(input())
hoge = [int(x) for x in input().split()]
_ = int(input())
for val in (int(x) for x in input().split()):
if exSearch(0, val, hoge):
print ('yes')
else:
print ('no')
| Traceback (most recent call last):
File "/tmp/tmprm0lsc3x/tmpf9yuuemj.py", line 9, in <module>
_ = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s837205995 | p02271 | u177808190 | 1518186474 | Python | Python3 | py | Runtime Error | 8750 | 5616 | 453 | def exSearch(i, m, hoge):
if m == 0:
return True
if i >= len(hoge):
return False
res = exSearch(i+1, m, hoge) or exSearch(i+1, m-hoge[i], hoge)
return res
if __name__ == '__main__':
_ = int(input())
hoge = [int(x) for x in input().split()]
_ = int(input())
for val in (int(x) for x in input().split()):
if exSearch(0, val, hoge):
print ('yes')
else:
print ('no')
| Traceback (most recent call last):
File "/tmp/tmp04nexgud/tmp18u_erz9.py", line 10, in <module>
_ = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s886214169 | p02271 | u177808190 | 1518186802 | Python | Python3 | py | Runtime Error | 9210 | 5616 | 422 | _ = int(input())
hoge = [int(x) for x in input().split()]
_ = int(input())
def exSearch(i, m):
if m == 0:
return True
if i >= len(hoge):
return False
res = exSearch(i+1, m) or exSearch(i+1, m-hoge[i])
return res
if __name__ == '__main__':
for val in (int(x) for x in input().split()):
if exSearch(0, val):
print ('yes')
else:
print ('no')
| Traceback (most recent call last):
File "/tmp/tmpu7dbh5w6/tmpzgipemod.py", line 1, in <module>
_ = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s942947449 | p02271 | u177808190 | 1518186907 | Python | Python3 | py | Runtime Error | 0 | 0 | 372 | num_n = int(input())
n = map(int, input().split())
num_m = int(input())
m = map(int, input().split())
def solve(i, m):
if m == 0:
return True
if i >= num_n or m > sum(n):
return False
res = solve(i + 1, m) or solve(i + 1,m - n[i])
return res
for k in range(num_m):
if solve(0, m[k]):
print ("yes")
else:
print ("no")
| Traceback (most recent call last):
File "/tmp/tmprrmfth_o/tmpmgobrda3.py", line 1, in <module>
num_n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s603526778 | p02271 | u996463517 | 1518325361 | Python | Python3 | py | Runtime Error | 6980 | 8024 | 457 | def solve(a,m):
S = []
ans = []
tmp = 0
for i in range(1,2**len(a)):
S.append(str(format(i,'b').zfill(len(a))))
for s in S:
for j in range(len(a)):
if s[j] == '1':
tmp += a[j]
if tmp == m:return 'yes'
tmp = 0
else:return 'no'
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
M = [int(i) for i in input().split()]
for m in M:
print(solve(a,m))
| Traceback (most recent call last):
File "/tmp/tmp8yy9e754/tmpd3kui_tb.py", line 15, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s795017204 | p02271 | u996463517 | 1518326382 | Python | Python3 | py | Runtime Error | 6840 | 5612 | 351 | def solve2(i,m,a,n):
if m == 0:
return True
if i >= n:
return False
res = solve2(i+1,m,a,n) or solve2(i+1,m-a[i],a,n)
return res
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
M = [int(i) for i in input().split()]
for m in M:
if solve2(0,m,a,n):
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmpdlfkt1dm/tmp49rpeh0n.py", line 9, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s655141995 | p02271 | u996463517 | 1518326677 | Python | Python3 | py | Runtime Error | 0 | 0 | 375 | @functools.lru_cache()
def solve2(i,m,a,n):
if m == 0:
return True
if i >= n:
return False
res = solve2(i+1,m,a,n) or solve2(i+1,m-a[i],a,n)
return res
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
M = [int(i) for i in input().split()]
for m in M:
if solve2(0,m,a,n):
print('yes')
else:
print('no')
| File "/tmp/tmpfx7rs0pi/tmpje5swjc_.py", line 1
@functools.lru_cache()
IndentationError: unexpected indent
| |
s809876291 | p02271 | u996463517 | 1518326695 | Python | Python3 | py | Runtime Error | 0 | 0 | 374 | @functools.lru_cache()
def solve2(i,m,a,n):
if m == 0:
return True
if i >= n:
return False
res = solve2(i+1,m,a,n) or solve2(i+1,m-a[i],a,n)
return res
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
M = [int(i) for i in input().split()]
for m in M:
if solve2(0,m,a,n):
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmp0hzvda3e/tmpkk4wwx6r.py", line 1, in <module>
@functools.lru_cache()
^^^^^^^^^
NameError: name 'functools' is not defined
| |
s867865220 | p02271 | u996463517 | 1518326817 | Python | Python3 | py | Runtime Error | 9110 | 6292 | 393 | import functools
@functools.lru_cache()
def solve2(i,m,):
if m == 0:
return True
if i >= n:
return False
res = solve2(i+1,m) or solve2(i+1,m-a[i])
return res
global n
global a
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
M = [int(i) for i in input().split()]
for m in M:
if solve2(0,m):
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmpedxowqxw/tmp3ohlzhm3.py", line 12, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s879197396 | p02271 | u150984829 | 1518627252 | Python | Python3 | py | Runtime Error | 0 | 0 | 234 | n=int(input())
A=list(map(int,input().split()))
r=set()
def f(s,k):
if k>=0:
global r
r|=set(s)
f(s+A[k-1],k-1)
f(s,k-1)
f(0,n)
input()
for e in map(int,input().split()):print(['no','yes'][e in r])
| Traceback (most recent call last):
File "/tmp/tmpek5qon26/tmpztqxum8j.py", line 1, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s571055719 | p02271 | u238001675 | 1519626818 | Python | Python3 | py | Runtime Error | 4860 | 5620 | 528 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
def solve(p, t, A):
if A[p] == t:
return True
if len(A)-1 == p:
return False
if solve(p+1, t-A[p], A):
return True
if solve(p+1, t, A):
return True
return False
import sys
n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
num_q = int(sys.stdin.readline())
query = list(map(int, sys.stdin.readline().split()))
for m in query:
if solve(0, m, A):
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmpsx_nji_v/tmpit1kap2z.py", line 17, in <module>
n = int(sys.stdin.readline())
^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s375620522 | p02271 | u912143677 | 1520320967 | Python | Python3 | py | Runtime Error | 7440 | 5608 | 329 | n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
def f(i, m):
if m == 0:
return True
elif i >= n:
return False
elif f(i+1, m):
return True
elif f(i+1, m-a[i]):
return True
for k in m:
print('yes' if f(0, k) else 'no')
| Traceback (most recent call last):
File "/tmp/tmpj6d1jvgp/tmpelooar5w.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s942248901 | p02271 | u912143677 | 1520321390 | Python | Python3 | py | Runtime Error | 9160 | 5612 | 367 | n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
def f(i, m):
if m == 0:
return True
elif m < 0:
return False
elif i >= n:
return False
elif f(i+1, m):
return True
elif f(i+1, m-a[i]):
return True
for k in m:
print('yes' if f(0, k) else 'no')
| Traceback (most recent call last):
File "/tmp/tmpmx49s007/tmp91gdhav9.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s051620960 | p02271 | u613534067 | 1520838462 | Python | Python3 | py | Runtime Error | 16850 | 5608 | 433 | def calc(a, m, x):
if a == []:
return False
y = a[0]
if x == m:
return True
elif (x + y) == m:
return True
else:
return calc(a[1:], m, x) or calc(a[1:], m, x + y) or calc(a[1:], m, y)
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for mi in m:
if calc(a[:], mi, 0):
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmpdvus9d8k/tmp0212o6yo.py", line 12, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s713964311 | p02271 | u613534067 | 1520838715 | Python | Python3 | py | Runtime Error | 10260 | 5612 | 412 | def calc(a, m, x):
if a == []:
return False
y = a[0]
if x == m:
return True
elif (x + y) == m:
return True
else:
return calc(a[1:], m, x) or calc(a[1:], m, x + y)
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for mi in m:
if calc(a[:], mi, 0):
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmpps2ivuet/tmplrf143n4.py", line 12, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s296121266 | p02271 | u613534067 | 1520838995 | Python | Python3 | py | Runtime Error | 9890 | 5612 | 412 | def calc(a, m, x):
if a == []:
return False
y = a[0]
if x == m:
return True
elif (x + y) == m:
return True
else:
return calc(a[1:], m, x) or calc(a[1:], m, x + y)
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for mi in m:
if calc(a[:], mi, 0):
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmp6sov3hsc/tmpqcs3lfp8.py", line 12, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s111178478 | p02271 | u613534067 | 1520839176 | Python | Python3 | py | Runtime Error | 9860 | 5612 | 409 | def calc(a, m, x):
if a == []:
return False
y = a[0]
if x == m:
return True
elif (x + y) == m:
return True
else:
return calc(a[1:], m, x + y) or calc(a[1:], m, x)
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for mi in m:
if calc(a, mi, 0):
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmpew3u0fjm/tmpxptyx4vc.py", line 12, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s303889085 | p02271 | u613534067 | 1520839523 | Python | Python3 | py | Runtime Error | 9420 | 5612 | 372 | def calc(a, m, x):
if a == []:
return False
y = a[0]
if (x + y) == m:
return True
else:
return calc(a[1:], m, x) or calc(a[1:], m, x + y)
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for mi in m:
if calc(a, mi, 0):
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmp1k4rlhsv/tmpl89pxay7.py", line 10, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s902206378 | p02271 | u152639966 | 1521747812 | Python | Python3 | py | Runtime Error | 12610 | 5612 | 264 | n=int(input())
A=input().split(' ')
q=input()
M=input().split(' ')
def solve(i,m):
if m==0:
return(True)
if i>=n:
return(False)
res=solve(i+1,m) or solve(i+1,m-int(A[i]))
return(res)
for j in M:
if solve(0,int(j)):
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmpbh9bqdfw/tmp8go3zubo.py", line 1, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s014283428 | p02271 | u912143677 | 1522388594 | Python | Python3 | py | Runtime Error | 10480 | 5608 | 366 | n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
def f(i, m):
if m == 0:
return True
elif m < 0:
return False
elif i >= n:
return False
elif f(i+1, m):
return True
elif f(i+1, m-a[i]):
return True
for k in m:
print('yes' if f(0, k) else 'no')
| Traceback (most recent call last):
File "/tmp/tmpe1uw73yq/tmpv3d6t0h3.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s748731178 | p02271 | u912143677 | 1522388991 | Python | Python3 | py | Runtime Error | 8880 | 5612 | 397 | n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
def f(i, m):
if m == 0:
return True
elif m < 0:
return False
elif i >= n:
return False
elif f(i+1, m):
return True
elif f(i+1, m-a[i]):
return True
else:
return False
for k in m:
print('yes' if f(0, k) else 'no')
| Traceback (most recent call last):
File "/tmp/tmpg5bxbol0/tmpqu98ai37.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s864090472 | p02271 | u912143677 | 1522389668 | Python | Python3 | py | Runtime Error | 0 | 0 | 542 | n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
memory = [[-1 for i in range(q)]for j in range(n)]
def f(i, m):
if memory[i][m] != -1:
return memory[i][m]
if m == 0:
return 1
elif m < 0:
return 0
elif i >= n:
return 0
elif f(i+1, m):
memory[i+1][m] = 1
return 1
elif f(i+1, m-a[i]):
memory[i+1][m-a[i]] = 1
return 1
else:
return 0
for k in m:
print('yes' if f(0, k) else 'no')
| Traceback (most recent call last):
File "/tmp/tmpuyk8cxt8/tmpxrdwz77g.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s132491611 | p02271 | u091332835 | 1522390597 | Python | Python3 | py | Runtime Error | 12310 | 5624 | 418 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
T = pow(2,n)-1
for k in range(q):
z = 0
for i in range(T):
B = list(format(i,"0"+str(n)+"b"))
sum = 0
for j in range(n):
sum += A[j]*int(B[j])
if sum == m[k]:
z =1
break
if z==1:
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmp719gmkft/tmp6b6p17pt.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s946568774 | p02271 | u912143677 | 1522393336 | Python | Python3 | py | Runtime Error | 0 | 0 | 676 | n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
memory = [[-1 for i in range(2000)]for j in range(n)]
def f(i, k, sum):
if memory[i][sum] != -1:
return memory[i][sum]
if sum == k:
memory[i][sum] = 1
return 1
elif sum > k:
memory[i][sum] = 0
return 0
elif i >= n:
return 0
else:
res0 = f(i+1, k, sum)
res1 = f(i+1, k, sum + a[i])
if res0 or res1:
memory[i][sum] = 1
return 1
else:
memory[i][m] = 0
return 0
for k in m:
print('yes' if f(0, k, 0) else 'no')
| Traceback (most recent call last):
File "/tmp/tmpws9w_5yj/tmpjzaproim.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s079776755 | p02271 | u912143677 | 1522395100 | Python | Python3 | py | Runtime Error | 12350 | 5612 | 450 | n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
def f(i, m):
if m == 0:
return 1
elif i >= n:
return 0
elif m - a[i] >= 0:
res0 = f(i+1, m)
res1 = f(i+1, m-a[i])
if res0 or res1:
return 1
else:
return 0
else:
res = f(i+1, m)
return res
for k in m:
print('yes' if f(0, k) else 'no')
| Traceback (most recent call last):
File "/tmp/tmpwg8haapb/tmp6utxcuwk.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s600095616 | p02271 | u912143677 | 1522395122 | Python | Python3 | py | Runtime Error | 12270 | 5612 | 450 | n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
def f(i, m):
if m == 0:
return 1
elif i >= n:
return 0
elif m - a[i] >= 0:
res0 = f(i+1, m)
res1 = f(i+1, m-a[i])
if res0 or res1:
return 1
else:
return 0
else:
res = f(i+1, m)
return res
for k in m:
print('yes' if f(0, k) else 'no')
| Traceback (most recent call last):
File "/tmp/tmp63hhgjzl/tmpli9v5znu.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s950434626 | p02271 | u912143677 | 1522395139 | Python | Python3 | py | Runtime Error | 12380 | 5612 | 450 | n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
def f(i, m):
if m == 0:
return 1
elif i >= n:
return 0
elif m - a[i] >= 0:
res0 = f(i+1, m)
res1 = f(i+1, m-a[i])
if res0 or res1:
return 1
else:
return 0
else:
res = f(i+1, m)
return res
for k in m:
print('yes' if f(0, k) else 'no')
| Traceback (most recent call last):
File "/tmp/tmpplg89v6i/tmptpmfns5i.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s071584696 | p02271 | u091332835 | 1522400394 | Python | Python3 | py | Runtime Error | 20 | 5592 | 511 | n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
def agari(i):
if X[i]==1:
X[i]=0
agari(i+1)
else:
X[i]=1
for j in range(q):
k = 0
flag = 0
X = [0] * 10
while k<(pow(2,n)-1):
y = 0
for l in range(n):
y += A[l]*X[l]
if y == m[j]:
flag = 1
break
agari(0)
k+=1
if flag == 1:
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmp3rq0mv9g/tmp3n61al5q.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s536288950 | p02271 | u138546245 | 1523935298 | Python | Python3 | py | Runtime Error | 19430 | 92844 | 1642 | class Tree:
class Node:
def __init__(self, n):
self.left = None
self.right = None
self.n = n
def find(self, total):
if total == 0:
return True
elif total < 0:
return False
if self.left is None:
left = (total == self.n)
else:
left = self.left.find(total-self.n)
if self.right is None:
right = False
else:
right = self.right.find(total)
return left or right
def __str__(self):
cs = []
if self.left is not None:
cs.append(str(self.left))
if self.right is not None:
cs.append(str(self.right))
return "{} -> ({})".format(self.n, ",".join(cs))
def __init__(self, ns):
self.top = self.Node(0)
self.build_node(self.top, sorted(ns))
def has_subset(self, total):
return self.top.find(total)
def build_node(self, node, ns):
if len(ns) == 0:
return
node.left = self.Node(ns[-1])
node.right = self.Node(ns[-1])
self.build_node(node.left, ns[:-1])
self.build_node(node.right, ns[:-1])
def run():
_ = int(input()) # flake8: noqa
ns = [int(i) for i in input().split()]
tree = Tree(ns)
_ = int(input()) # flake8: noqa
for q in (int(j) for j in input().split()):
if tree.has_subset(q):
print("yes")
else:
print("no")
if __name__ == '__main__':
run()
| Traceback (most recent call last):
File "/tmp/tmpdi5csjcj/tmpcbrrdwjz.py", line 68, in <module>
run()
File "/tmp/tmpdi5csjcj/tmpcbrrdwjz.py", line 54, in run
_ = int(input()) # flake8: noqa
^^^^^^^
EOFError: EOF when reading a line
| |
s528329939 | p02271 | u138546245 | 1523936971 | Python | Python3 | py | Runtime Error | 7770 | 49284 | 1607 | class Tree:
class Node:
def __init__(self, n):
self.left = None
self.right = None
self.n = n
def find(self, total):
if total == self.n:
return True
elif total < self.n:
return (self.right is not None
and self.right.find(total))
else:
return ((self.left is not None
and self.left.find(total-self.n))
or
(self.right is not None
and self.right.find(total)))
def __str__(self):
cs = []
if self.left is not None:
cs.append(str(self.left))
if self.right is not None:
cs.append(str(self.right))
return "{} -> ({})".format(self.n, ",".join(cs))
def __init__(self, ns):
self.top = self.build_nodes(sorted(ns))
def has_subset(self, total):
return self.top.find(total)
def build_nodes(self, ns):
if len(ns) == 0:
return
node = self.Node(ns[-1])
node.left = self.build_nodes(ns[:-1])
node.right = self.build_nodes(ns[:-1])
return node
def run():
_ = int(input()) # flake8: noqa
ns = [int(i) for i in input().split()]
tree = Tree(ns)
_ = int(input()) # flake8: noqa
for q in (int(j) for j in input().split()):
if tree.has_subset(q):
print("yes")
else:
print("no")
if __name__ == '__main__':
run()
| Traceback (most recent call last):
File "/tmp/tmp0q305sht/tmpel9957tk.py", line 63, in <module>
run()
File "/tmp/tmp0q305sht/tmpel9957tk.py", line 49, in run
_ = int(input()) # flake8: noqa
^^^^^^^
EOFError: EOF when reading a line
| |
s267586890 | p02271 | u464859367 | 1524327679 | Python | Python3 | py | Runtime Error | 0 | 0 | 404 | # jは目的の値, iは要素のリストのキー
def solve(i, j):
global a, A
if j == 0:
return True
if i >= a:
return False
# 左はA[i]の要素を使用しない場合、右は使用する場合
res = solve(i + 1, j) or solve(i + 1, j - A[i])
return res
for m in M:
r = solve(0, m)
if r is True:
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmp3ntpd0zs/tmpbo76qtl7.py", line 13, in <module>
for m in M:
^
NameError: name 'M' is not defined
| |
s018715619 | p02271 | u464859367 | 1524327695 | Python | Python3 | py | Runtime Error | 7940 | 5612 | 515 | a = int(input())
A = list(map(int, input().split()))
N = int(input())
M = list(map(int, input().split()))
# jは目的の値, iは要素のリストのキー
def solve(i, j):
global a, A
if j == 0:
return True
if i >= a:
return False
# 左はA[i]の要素を使用しない場合、右は使用する場合
res = solve(i + 1, j) or solve(i + 1, j - A[i])
return res
for m in M:
r = solve(0, m)
if r is True:
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmp_qfi2eoe/tmpocozb_ba.py", line 1, in <module>
a = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s287800530 | p02271 | u464859367 | 1524328058 | Python | Python3 | py | Runtime Error | 0 | 0 | 505 | a = input()
A = list(map(int, input().split()))
N = input()
M = list(map(int, input().split()))
# jは目的の値, iは要素のリストのキー
def solve(i, j):
global a, A
if j == 0:
return True
if i >= a:
return False
# 左はA[i]の要素を使用しない場合、右は使用する場合
res = solve(i + 1, j) or solve(i + 1, j - A[i])
return res
for m in M:
r = solve(0, m)
if r is True:
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmp7pvij12s/tmpqpslobn7.py", line 1, in <module>
a = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s293785028 | p02271 | u464859367 | 1524328089 | Python | Python3 | py | Runtime Error | 7980 | 5612 | 510 | a = int(input())
A = list(map(int, input().split()))
N = input()
M = list(map(int, input().split()))
# jは目的の値, iは要素のリストのキー
def solve(i, j):
global a, A
if j == 0:
return True
if i >= a:
return False
# 左はA[i]の要素を使用しない場合、右は使用する場合
res = solve(i + 1, j) or solve(i + 1, j - A[i])
return res
for m in M:
r = solve(0, m)
if r is True:
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmpt4wzgql8/tmp4duzx877.py", line 1, in <module>
a = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s283074008 | p02271 | u126478680 | 1525246168 | Python | Python3 | py | Runtime Error | 13200 | 12464 | 732 | import copy
combinations = []
def make_combination(n):
S = [0 for i in range(n)]
rec(0, n, S)
def rec(i, n, S):
global combinations
if i == n:
combinations.append(copy.copy(S))
return None
rec(i+1, n, S)
S[i] = 1
rec(i+1, n, S)
S[i] = 0
n = int(input())
A = [int(x) for x in input().split(' ')]
q = int(input())
M = [int(x) for x in input().split(' ')]
make_combination(n)
for m in M:
flag = False
for co in combinations:
sum = 0
for i in range(n):
sum += A[i] * co[i]
if sum >= m:
break
if sum == m:
flag = True
break
if flag:
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmp016xfe38/tmp9q4arlqw.py", line 18, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s218004328 | p02271 | u126478680 | 1525246254 | Python | Python3 | py | Runtime Error | 12610 | 12468 | 729 | import copy
combinations = []
def make_combination(n):
S = [0 for i in range(n)]
rec(0, n, S)
def rec(i, n, S):
global combinations
if i == n:
combinations.append(copy.copy(S))
return None
rec(i+1, n, S)
S[i] = 1
rec(i+1, n, S)
S[i] = 0
n = int(input())
A = list(map(int, input().split(' ')))
q = int(input())
M = list(map(int, input().split(' ')))
make_combination(n)
for m in M:
flag = False
for co in combinations:
sum = 0
for i in range(n):
sum += A[i] * co[i]
if sum >= m:
break
if sum == m:
flag = True
break
if flag:
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmp3ehl7hpg/tmpii7u86xl.py", line 18, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s718826848 | p02271 | u255317651 | 1525266851 | Python | Python3 | py | Runtime Error | 7020 | 5672 | 684 | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for i in m:
yesorno = False
b = []
for j in a:
if j <= i:
b.append(j)
#print(b)
if len(b)>=1:
for r in range(1, len(b)+1):
for comb in itr.combinations(b,r):
#print(i,comb)
if sum(comb) == i:
yesorno = True
break
if yesorno:
break
if yesorno:
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmpgof5qu14/tmp35gue435.py", line 9, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s318987046 | p02271 | u255317651 | 1525267666 | Python | Python3 | py | Runtime Error | 7360 | 5672 | 684 | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for i in m:
yesorno = False
b = []
for j in a:
if j <= i:
b.append(j)
#print(b)
if len(b)>=1:
for r in range(1, len(b)+1):
for comb in itr.combinations(b,r):
#print(i,comb)
if sum(comb) == i:
yesorno = True
break
if yesorno:
break
if yesorno:
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmporkkkdz2/tmp22lw4478.py", line 9, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s542060526 | p02271 | u255317651 | 1525270202 | Python | Python3 | py | Runtime Error | 0 | 0 | 721 | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for i in m:
yesorno = False
b = []
for j in a:
if j <= i:
b.append(j)
#print(b)
lb = len(b)
if lb >= 1:
for r in range(1, 2**lb):
bin_str = format(r, 'b')
sumb = sum([b[k]*int(bin_str[k]) for k in range(lb)]) #print(i,comb)
if sumb == i:
yesorno = True
break
if yesorno:
break
if yesorno:
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmpz1932uma/tmpir8p4bps.py", line 9, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s668867754 | p02271 | u255317651 | 1525270492 | Python | Python3 | py | Runtime Error | 9510 | 5692 | 755 | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for i in m:
yesorno = False
b = []
for j in a:
if j <= i:
b.append(j)
#print(b)
lb = len(b)
if lb >= 1:
for r in range(1, 2**lb):
fmt = '0'+str(lb)+'b'
bin_str = format(r, fmt)
sumb = sum([b[k]*int(bin_str[k]) for k in range(lb)]) #print(i,comb)
if sumb == i:
yesorno = True
break
if yesorno:
break
if yesorno:
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmprj64dgc9/tmpd5fyhlg_.py", line 9, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s322116217 | p02271 | u255317651 | 1525305501 | Python | Python3 | py | Runtime Error | 0 | 0 | 480 | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
sum_array = []
for r in range(1,n+1):
for comb in itr.combinations(a, r):
aum_array.append[sum(comb)]
for i in m:
yesorno = 'no'
for j in sum_array:
if i == j:
yesorno == 'yes'
break
print('yes')
| Traceback (most recent call last):
File "/tmp/tmpmcdtdobn/tmpbxel2ne2.py", line 9, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s694405610 | p02271 | u255317651 | 1525305534 | Python | Python3 | py | Runtime Error | 0 | 0 | 480 | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
sum_array = []
for r in range(1,n+1):
for comb in itr.combinations(a, r):
sum_array.append[sum(comb)]
for i in m:
yesorno = 'no'
for j in sum_array:
if i == j:
yesorno == 'yes'
break
print('yes')
| Traceback (most recent call last):
File "/tmp/tmp0b9rkpie/tmpeyjwaoy1.py", line 9, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s335596441 | p02271 | u255317651 | 1525316662 | Python | Python3 | py | Runtime Error | 7020 | 5632 | 612 | # -*- coding: utf-8 -*-
"""
Created on Thu May 3 11:39:47 2018
@author: maezawa
"""
# -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a_r2
@author: maezawa
"""
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m_array = list(map(int, input().split()))
def can_comp(i, m): #i番目以降の数列をつかってmを作れるか?
if m == 0:
return True
elif i == n:
return False
else:
return can_comp(i+1, m) or can_comp(i+1, m-a[i])
for m in m_array:
if can_comp(0, m):
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmpgekxmyd2/tmpxhiawnwk.py", line 15, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s230929022 | p02271 | u605879293 | 1525333114 | Python | Python3 | py | Runtime Error | 7740 | 5616 | 384 | global n
n = int(input())
a_array = [int(x) for x in input().split()]
q = int(input())
m_array = [int(x) for x in input().split()]
def solve(a, m):
if m == 0:
return True
if a >= n:
return False
res = solve(a + 1, m) or solve(a + 1, m - a_array[a])
return res
for m in m_array:
if solve(0, m):
print("yes")
else:
print("no")
| Traceback (most recent call last):
File "/tmp/tmpqcisfz1i/tmppbrwieu8.py", line 2, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s486965421 | p02271 | u255317651 | 1525342375 | Python | Python3 | py | Runtime Error | 0 | 0 | 921 |
# -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a_r2 Time Limit Exceeded
@author: maezawa
"""
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m_array = list(map(int, input().split()))
can_c_array = [[None for _ in range(m)] for _ in range(n)]
def can_comp(i, m): #i番目以降の数列をつかってmを作れるか?
if m == 0:
return True
elif i == n:
return False
else:
if can_c_array[i+1][m] == None:
c1 = can_comp(i+1, m)
can_c_array[i+1][m] = c1
else:
c1 = can_c_array[i+1][m]
if can_c_array[i+1][m-a[i]] == None:
c2 = can_comp(i+1, m-a[i])
can_c_array[i+1][m-a[i]] = c2
else:
c2 = can_c_array[i+1][m-a[i]]
return c1 or c2
for m in m_array:
if can_comp(0, m):
print('yes')
else:
print('no')
| Traceback (most recent call last):
File "/tmp/tmpdth2ft9r/tmp4hv1wmiu.py", line 9, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.