s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s320995653 | p02271 | u604774382 | 1437315584 | Python | Python3 | py | Runtime Error | 0 | 0 | 101 | isExist = [False]*2001
n = int( input() )
q = int( input() )
for i in range( 0, 3 ):
print( "yes" ) |
s325178028 | p02271 | u604774382 | 1437315698 | Python | Python3 | py | Runtime Error | 0 | 0 | 97 | isExist = [0]*2001
n = int( input() )
q = int( input() )
for i in range( 0, 3 ):
print( "yes" ) |
s485191781 | p02271 | u604774382 | 1437315830 | Python | Python3 | py | Runtime Error | 0 | 0 | 356 | isExist = [0]*2001
n = int( input() )
A = [ int( val ) for val in input().split( ' ' ) ]
for i in A:
for j in range( 2000-i, 0, -1 ):
if 1 == isExist[j]:
isExist[ i+j ] = 1
isExist[i] = 1
q = int( input() )
M = [ int( val ) for val in input().split( ' ' ) ]
for i in range( 0, q ):
if 1 == isExist[ M[i] ]:
print( "yes" )
else:
print( "no" ) |
s657218292 | p02271 | u604774382 | 1437315877 | Python | Python3 | py | Runtime Error | 0 | 0 | 249 | isExist = [0]*2001
n = int( input() )
A = [ int( val ) for val in input().split( ' ' ) ]
q = int( input() )
M = [ int( val ) for val in input().split( ' ' ) ]
for i in range( 0, q ):
if 1 == isExist[ M[i] ]:
print( "yes" )
else:
print( "no" ) |
s355865467 | p02271 | u604774382 | 1437315896 | Python | Python3 | py | Runtime Error | 0 | 0 | 147 | isExist = [0]*2001
n = int( input() )
q = int( input() )
for i in range( 0, q ):
if 1 == isExist[ M[i] ]:
print( "yes" )
else:
print( "no" ) |
s748917348 | p02271 | u604774382 | 1437315920 | Python | Python3 | py | Runtime Error | 0 | 0 | 97 | isExist = [0]*2001
n = int( input() )
q = int( input() )
for i in range( 0, q ):
print( "yes" ) |
s119285275 | p02271 | u604774382 | 1437315943 | Python | Python3 | py | Runtime Error | 0 | 0 | 97 | isExist = [0]*2001
n = int( input() )
d = int( input() )
for i in range( 0, d ):
print( "yes" ) |
s033166049 | p02271 | u604774382 | 1437315956 | Python | Python3 | py | Runtime Error | 0 | 0 | 97 | isExist = [0]*2001
n = int( input() )
d = int( input() )
for i in range( 0, 5 ):
print( "yes" ) |
s607872581 | p02271 | u604774382 | 1437315979 | Python | Python3 | py | Runtime Error | 0 | 0 | 77 | n = int( input() )
d = int( input() )
for i in range( 0, 5 ):
print( "yes" ) |
s098199995 | p02271 | u604774382 | 1437316060 | Python | Python3 | py | Runtime Error | 0 | 0 | 77 | a = int( input() )
d = int( input() )
for i in range( 0, 5 ):
print( "yes" ) |
s873640007 | p02271 | u604774382 | 1437316173 | Python | Python3 | py | Runtime Error | 0 | 0 | 179 | n = int( input() )
A = [ int( val ) for val in input().split( ' ' ) ]
q = int( input() )
M = [ int( val ) for val in input().split( ' ' ) ]
for i in range( 0, q ):
print( "yes" ) |
s702405325 | p02271 | u604774382 | 1437316271 | Python | Python3 | py | Runtime Error | 0 | 0 | 179 | n = int( input() )
A = [ int( val ) for val in input().split( ' ' ) ]
q = int( input() )
z = [ int( val ) for val in input().split( ' ' ) ]
for i in range( 0, q ):
print( "yes" ) |
s257235149 | p02271 | u604774382 | 1437316358 | Python | Python3 | py | Runtime Error | 0 | 0 | 246 | import sys
n = int( sys.stdin.readline( ) )
A = [ int( val ) for val in sys.stdin.readline( ).split( ' ' ) ]
q = int( sys.stdin.readline( ) )
z = [ int( val ) for val in sys.stdin.readline( ).split( ' ' ) ]
for i in range( 0, q ):
print( "yes" ) |
s074872966 | p02271 | u604774382 | 1437316471 | Python | Python3 | py | Runtime Error | 0 | 0 | 193 | n = int( input( ) )
t = [ int( val ) for val in input( ).rstrip( ).split( " " ) ]
q = int( input( ) )
s = [ int( val ) for val in input( ).split( " " ) ]
for i in range( 0, q ):
print( "yes" ) |
s062854307 | p02271 | u604774382 | 1437316544 | Python | Python3 | py | Runtime Error | 0 | 0 | 230 | import sys
n = int( sys.stdin.readline( ) )
A = [ int( val ) for val in input( ).rstrip( ).split( " " ) ]
q = int( sys.stdin.readline( ) )
M = [ int( val ) for val in input( ).split( " " ) ]
for i in range( 0, q ):
print( "yes" ) |
s644923132 | p02271 | u604774382 | 1437316689 | Python | Python3 | py | Runtime Error | 30 | 6724 | 366 | isExist = [0]*2001
n = int( input() )
A = [ int( val ) for val in input().split( ' ' ) ]
for i in A:
for j in range( 2000-i, 0, -1 ):
if 1 == isExist[j]:
isExist[ i+j ] = 1
isExist[i] = 1
q = int( input() )
M = [ int( val ) for val in input().rstrip( ).split( ' ' ) ]
for i in range( 0, q ):
if 1 == isExist[ M[i] ]:
print( "yes" )
else:
print( "no" ) |
s904051991 | p02271 | u604774382 | 1437317103 | Python | Python3 | py | Runtime Error | 0 | 0 | 396 | def solve( p, t ):
global isExist, n, A
isExist[ t ] = True
if p < n:
solve( p+1, t-A[p] )
solve( p+1, t )
else:
return
isExist = [False]*2001
n = int( input() )
A = map( int, input().rstrip().split( " " ) )
q = int( input() )
M = map( int, input().rstrip().split( " " ) )
s = sum( A )
solve( 0, s )
for i in range( 0, q ):
if isExist[ M[i] ]:
print( "yes" )
else:
print( "no" ) |
s084095078 | p02271 | u882992966 | 1441962332 | Python | Python3 | py | Runtime Error | 0 | 0 | 569 | import sys
def search_combination(elements, target):
if len(elements) == 0:
if target == 0:
return True
else:
return False
return search_combination(elements[1:], target - elements[0]) or search_combination(elements[1:], target)
if __name__ == "__main__":
lines = sys.stdin.readlines()
elements = [int(x) for x in lines[1].split(" ")]
targets = [int(x) for x in lines[3].split(" ")]
for target in targets:
result = "yes" if search_combination(elements, target) else "no"
print(result) |
s697653821 | p02271 | u882992966 | 1441962457 | Python | Python3 | py | Runtime Error | 0 | 0 | 593 | #!/usr/bin/env python3
import sys
def search_combination(elements, target):
if len(elements) == 0:
if target == 0:
return True
else:
return False
return search_combination(elements[1:], target - elements[0]) or search_combination(elements[1:], target)
if __name__ == "__main__":
lines = sys.stdin.readlines()
elements = [int(x) for x in lines[1].split(" ")]
targets = [int(x) for x in lines[3].split(" ")]
for target in targets:
result = "yes" if search_combination(elements, target) else "no"
print(result) |
s556811716 | p02271 | u949338836 | 1446037934 | Python | Python3 | py | Runtime Error | 0 | 0 | 355 | #coding:utf-8
#1_5_A
def solve(i, m):
if m == 0:
return True
if i >= n:
return False
res = solve(i+1, m) or solve(i+1, m-numbers[i])
return res
n = int(input())
numbers = list(map(int, input().split()))
q = int(input())
for i in range(q):
if solve(0, int(input())):
print("yes")
else:
print("no") |
s881037416 | p02271 | u488601719 | 1448255537 | Python | Python3 | py | Runtime Error | 0 | 0 | 332 | 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 >= m):
return False
return solve(i+1, m) or solve(i+1, m-A[i])
for m in M:
if (solve(0, m)):
print("yes")
else:
print("no") |
s517705899 | p02271 | u881590806 | 1448673583 | Python | Python | py | Runtime Error | 0 | 0 | 534 | n = int(raw_input())
A = map(int, raw_input().split(' '))
q = int(raw_input())
M = map(int, raw_input().split(' '))
S = [0]*len(A)
flags = [False]*len(M)
def brute_force(n):
if n == len(S):
ans = 0
for i in range(len(S)):
if S[i] == 1: ans += A[i]
for i in range(len(M)):
if ans == M[i]: flags[i] = True
else:
S[n] = 0
brute_force(n+1)
S[n] = 1
brute_force(n+1)
brute_force(0)
for flag in flags:
if flag: print "yes"
else: print "no" |
s404751872 | p02271 | u317901693 | 1451012948 | Python | Python3 | py | Runtime Error | 0 | 0 | 510 | # coding: utf-8
N = int(f.readline())
A = [int(i) for i in input().split()]
q = int(f.readline())
m = [int(i) for i in input().split()]
MAX_LENGTH = len(A)
#i番目以降の値を使ってmを作ればTrueを返す
def fullSearch(i, m):
#終了条件
if m == 0:
return True
elif i >= MAX_LENGTH:
return False
else:
#全探索かっこわるい
return fullSearch(i + 1, m) or fullSearch(i + 1, m - A[i])
for i in m:
print("yes" if fullSearch(0, i) else "no") |
s345589068 | p02271 | u970436839 | 1452650336 | Python | Python | py | Runtime Error | 0 | 0 | 269 | n = input()
A = map(int, raw_input().split())
q = input()
m = map(int, raw_input().split())
for i in range(q):
for j in range(n):
if A[n-j] < m[i]:
m[i] = m[i] - A[n-j]
if m[i] <= 0:
break
if m[i] == 0:
print "yes"
else:
print "no" |
s805452760 | p02271 | u038005340 | 1452651298 | Python | Python | py | Runtime Error | 0 | 0 | 283 | n = int( raw_input() )
A = map( int , raw_input().split() )
q = int( raw_input() )
m = map( int , raw_input().split() )
for i in n-1
def solve(i, m)
if m == 0
return true
if i >= n
return false
res = solve(i + 1, m) || solve(i + 1, m - A[i])
return res |
s732139694 | p02271 | u038005340 | 1452651405 | Python | Python | py | Runtime Error | 0 | 0 | 283 | n = int( raw_input() )
A = map( int , raw_input().split() )
q = int( raw_input() )
m = map( int , raw_input().split() )
for i in n-1
def solve(i, m)
if m == 0
return true
if i >= n
return false
res = solve( i+1 , m ) || solve( i+1 , m-A[i] )
return res |
s628453616 | p02271 | u038005340 | 1452651507 | Python | Python | py | Runtime Error | 0 | 0 | 301 | n = int( raw_input() )
A = map( int , raw_input().split() )
q = int( raw_input() )
m = map( int , raw_input().split() )
for i in range( len(A) + 1 ):
def solve(i, m)
if m == 0:
return true
if i >= n:
return false
res = solve( i+1 , m ) | solve( i+1 , m-A[i] )
return res |
s766884062 | p02271 | u038005340 | 1452651545 | Python | Python | py | Runtime Error | 0 | 0 | 297 | n = int( raw_input() )
A = map( int , raw_input().split() )
q = int( raw_input() )
m = map( int , raw_input().split() )
for i in range( len(A) + 1 ):
def solve(i, m)
if m == 0:
return yes
if i >= n:
return no
res = solve( i+1 , m ) | solve( i+1 , m-A[i] )
return res |
s357405734 | p02271 | u038005340 | 1452651716 | Python | Python | py | Runtime Error | 0 | 0 | 297 | n = int( raw_input() )
A = map( int , raw_input().split() )
q = int( raw_input() )
m = map( int , raw_input().split() )
for i in range( len(A) + 1 ):
def solve(i, m)
if m == 0:
return yes
if i >= n:
return no
res = solve( i+1 , m ) | solve( i+1 , m-A[i] )
return res |
s363507697 | p02271 | u970436839 | 1452651836 | Python | Python | py | Runtime Error | 0 | 0 | 247 | n = input()
A = map(int, raw_input().split())
q = input()
m = map(int, raw_input().split())
for i in m:
for j in range(n):
if A[-j] <= i
i = i - A[-j]
if i <= 0:
break
if i == 0:
print "yes"
else:
print "no" |
s019022539 | p02271 | u970436839 | 1452651919 | Python | Python | py | Runtime Error | 0 | 0 | 305 | n = input()
A = {}
A = map(int, raw_input().split())
q = input()
m = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n:
return False
res = solve(i, m) or solve(i, m - A[i])
return res
for i in m:
if solve(0,i):
print "yes"
else:
print "no" |
s730755918 | p02271 | u038005340 | 1452652157 | Python | Python | py | Runtime Error | 0 | 0 | 297 | n = int( raw_input() )
A = map( int , raw_input().split() )
q = int( raw_input() )
m = map( int , raw_input().split() )
for i in range( len(A) + 1 ):
def solve(i, m)
if m == 0:
return yes
if i >= n:
return no
res = solve( i+1 , m ) | solve( i+1 , m-A[i] )
return res |
s879783691 | p02271 | u970436839 | 1452652200 | Python | Python | py | Runtime Error | 0 | 0 | 311 | n = input()
A = {}
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n:
return False
res = solve(i, m) or solve(i, m - A[i])
return res
for m in M:
if solve(0,m):
print "yes"
else:
print "no" |
s156533059 | p02271 | u038005340 | 1452652320 | Python | Python | py | Runtime Error | 0 | 0 | 289 | n = int( raw_input() )
A = map( int , raw_input().split() )
q = int( raw_input() )
m = map( int , raw_input().split() )
for i in range( len(A) + 1 ):
def solve(i, m)
if m == 0 or solve( i+1 , m ) or solve( i+1 , m-A[i] ):
return yes
if i >= n or m < 0:
return no
|
s768281349 | p02271 | u233232390 | 1452652377 | Python | Python | py | Runtime Error | 0 | 0 | 443 | n = raw_input()
A = map(int, raw_input().split())
d = {}
def solution(i, m, n):
if m == 0:
return True
if i >= n:
return False
if d.has_key((i, m)):
return d[(i, m)]
res = solution(i + 1, m, n) or solution(i + 1, m - A[i], n)
d[(i, m)] = res
return res
q = raw_input()
M = map(int, raw_input().split())
for m in M:
if solution(0, m, n):
print 'yes'
else:
print 'no' |
s955647523 | p02271 | u233232390 | 1452652459 | Python | Python | py | Runtime Error | 0 | 0 | 433 | n = raw_input()
A = map(raw_input().split())
d = {}
def solution(i, m, n):
if m == 0:
return True
if i >= n:
return False
if d.has_key((i, m)):
return d[(i, m)]
res = solution(i + 1, m, n) or solution(i + 1, m - A[i], n)
d[(i, m)] = res
return res
q = raw_input()
M = map(raw_input().split())
for m in M:
if solution(0, m, n):
print 'yes'
else:
print 'no' |
s811853474 | p02271 | u038005340 | 1452652525 | Python | Python | py | Runtime Error | 0 | 0 | 293 | n = int( raw_input() )
A = map( int , raw_input().split() )
q = int( raw_input() )
m = map( int , raw_input().split() )
for i in range( len(A) + 1 ):
def solve(i, m)
if m == 0 or solve( i+1 , m ) or solve( i+1 , m-A[i] ):
print 'yes'
if i >= n or m < 0:
print 'no'
|
s342634510 | p02271 | u038005340 | 1452652846 | Python | Python | py | Runtime Error | 0 | 0 | 376 | n = int( raw_input() )
A = map( int , raw_input().split() )
q = int( raw_input() )
mi = map( int , raw_input().split() )
for i in range( len(A) + 1 ):
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 mi
if solve( 0 , m ):
print 'yes'
else:
print 'no'
|
s542824476 | p02271 | u038005340 | 1452652890 | Python | Python | py | Runtime Error | 0 | 0 | 376 | n = int( raw_input() )
A = map( int , raw_input().split() )
q = int( raw_input() )
mi = map( int , raw_input().split() )
for i in range( len(A) + 1 ):
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 mi
if solve( 0 , m ):
print 'yes'
else:
print 'no'
|
s068466608 | p02271 | u038005340 | 1452652972 | Python | Python | py | Runtime Error | 0 | 0 | 310 | n = input()
A = map( int , raw_input().split() )
q = input()
mi = map( int , raw_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 mi
if solve( 0 , m ):
print 'yes'
else:
print 'no'
|
s752129650 | p02271 | u619765879 | 1452652974 | Python | Python | py | Runtime Error | 0 | 0 | 313 | def main():
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(q)
if solve(0, m[q], A)
for j in range()
def solve(int i, int m, A):
if m == 0:
return 1
if i >= n:
return 0
res = solve(i+1, m) or solve(i+1, m-A[i])
return res |
s235943855 | p02271 | u038005340 | 1452652998 | Python | Python | py | Runtime Error | 0 | 0 | 312 | n = input()
A = map( int , raw_input().split() )
q = input()
mi = map( int , raw_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 mi:
if solve( 0 , m ):
print 'yes'
else:
print 'no'
|
s475945675 | p02271 | u970436839 | 1452653002 | Python | Python | py | Runtime Error | 0 | 0 | 327 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n or m > sum(A)
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" |
s417091157 | p02271 | u834416077 | 1452653033 | Python | Python | py | Runtime Error | 0 | 0 | 297 | n = input()
a = []
b = []
for i in range(n):
a[i] = input()
m = input()
for j in range(m):
b[j] = input()
for j in range(m):
for i in range(n):
if b[j] - a[i] < 0:
i = i + 1
elif b[j] - a[i] == 0:
return yes
elif b[j] - a[i] > 0:
b[j] = b[j] - a[i]
return no |
s827073411 | p02271 | u619765879 | 1452653102 | Python | Python | py | Runtime Error | 0 | 0 | 340 | def main():
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(q)
if solve(0, m[q], A):
print 'yes'
else:
print 'no'
def solve(int i, int m, A):
if m == 0:
return 1
if i >= n:
return 0
res = solve(i+1, m) or solve(i+1, m-A[i])
return res |
s906448702 | p02271 | u619765879 | 1452653201 | Python | Python | py | Runtime Error | 0 | 0 | 303 | def solve(i, m, A):
if m == 0:
return 1
if i >= n:
return 0
res = solve(i+1, m) or solve(i+1, m-A[i])
return res
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(q)
if solve(0, m[q], A):
print 'yes'
else:
print 'no' |
s971744576 | p02271 | u619765879 | 1452653221 | Python | Python | py | Runtime Error | 0 | 0 | 297 | def solve(i, m):
if m == 0:
return 1
if i >= n:
return 0
res = solve(i+1, m) or solve(i+1, m-A[i])
return res
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(q)
if solve(0, m[q]):
print 'yes'
else:
print 'no' |
s507449931 | p02271 | u038005340 | 1452653251 | Python | Python | py | Runtime Error | 0 | 0 | 356 | n = int( raw_input() )
A = map( int , raw_input().strip().split(' ') )
q = int( raw_input() )
mi = map( int , raw_input().strip().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 mi:
if solve( 0 , m ):
print 'yes'
else:
print 'no'
|
s360963726 | p02271 | u619765879 | 1452653274 | Python | Python | py | Runtime Error | 0 | 0 | 321 | def solve(i, m, A, n):
if m == 0:
return 1
if i >= n:
return 0
res = solve(i+1, m, A, n) or solve(i+1, m-A[i], A, n)
return res
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(q)
if solve(0, m[q], A, n):
print 'yes'
else:
print 'no' |
s987333996 | p02271 | u834416077 | 1452653283 | Python | Python | py | Runtime Error | 0 | 0 | 278 | n = input()
a = []
b = []
for i in range(n):
a[i] = input()
m = input()
for j in range(m):
b[j] = input()
for i in range(n):
if b[j] - a[i] < 0:
i = i + 1
elif b[j] - a[i] == 0:
return yes
elif b[j] - a[i] > 0:
b[j] = b[j] - a[i]
return no |
s130360904 | p02271 | u038005340 | 1452653287 | Python | Python | py | Runtime Error | 0 | 0 | 355 | n = int( raw_input() )
A = map( int , raw_input().strip().split(' ') )
q = int( raw_input() )
mi = map( int , raw_input().strip().split(' ') )
def solve(i, m):
if m == 0:
return True
if i >= n:
return False
res = solve( i+1 , m ) | solve( i+1 , m-A[i] )
return res
for m in mi:
if solve( 0 , m ):
print 'yes'
else:
print 'no'
|
s699992317 | p02271 | u834416077 | 1452653662 | Python | Python | py | Runtime Error | 0 | 0 | 278 | n = input()
a = []
b = []
for i in range(n):
a[i] = input()
m = input()
for j in range(m):
b[j] = input()
for i in range(n):
if b[j] - a[i] < 0:
i = i + 1
elif b[j] - a[i] == 0:
return yes
elif b[j] - a[i] > 0:
b[j] = b[j] - a[i]
return no |
s192207651 | p02271 | u000228958 | 1452653713 | Python | Python3 | py | Runtime Error | 0 | 0 | 360 | def solve(i, m):
if m == 0:
return True
elif i >= n:
return False
if solve(i + 1, m) or solve(i + 1, m - A[i]) == True:
return True
else:
return False
n = input()
A = map(int, raw_input().split())
q = input()
m = map(int, raw_input().split())
for i in xrange(q):
if solve(0, m[i]) == True:
print "yes"
else:
print "no" |
s489072272 | p02271 | u613805578 | 1452653828 | Python | Python | py | Runtime Error | 0 | 0 | 369 | n = input()
A = []
for i in range(n):
A.append(int(raw_input()))
q = input()
M = []
for i in range(n):
M.append(int(raw_input()))
def solve(i, m)
if m == 0
return true
if i >= n
return false
res = solve(i + 1, m) || solve(i + 1, m - A[i])
return res
for i in range(len(M)):
if solve(0,m):
print "yes"
else:
print "no"
|
s289586433 | p02271 | u038005340 | 1452653901 | Python | Python | py | Runtime Error | 0 | 0 | 320 | n = input()
A = map( int , raw_input().split() )
q = input()
M = map( int , raw_input().split() )
def solve(i, m):
if m == 0:
return True
elif i >= n:
return False
else:
res = solve( i+1 , m ) | solve( i+1 , m-A[i] )
return res
for m in mi:
if solve( 0 , m ): print "yes"
else: print "no"
|
s493441711 | p02271 | u613805578 | 1452653921 | Python | Python | py | Runtime Error | 0 | 0 | 356 | n = input()
A = []
for i in range(n):
A.append(int(raw_input()))
q = input()
M = []
for i in range(n):
M.append(int(raw_input()))
def solve(i, m)
if m == 0
return true
if i >= n
return false
res = solve(i + 1, m) || solve(i + 1, m - A[i])
return res
for i in M:
if solve(0,m):
print "yes"
else:
print "no"
|
s968169962 | p02271 | u613805578 | 1452653946 | Python | Python | py | Runtime Error | 0 | 0 | 356 | n = input()
A = []
for i in range(n):
A.append(int(raw_input()))
q = input()
M = []
for i in range(n):
M.append(int(raw_input()))
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 M:
if solve(0,m):
print "yes"
else:
print "no"
|
s128050661 | p02271 | u047737909 | 1452654092 | Python | Python | py | Runtime Error | 0 | 0 | 307 | def fact(k):
if k == 0:
return 1
return k * fact(k - 1)
n = input()
a=[0]*n
for i in range(n):
a = input()
q = input()
m = [0]*q
for i in range(q):
m = input()
ans=[0]*fact(k)
for s in range(t):
for t in range(n):
ans[s*(t+1)] +=a[t]
if x in ams:
print'yes'
else:
print'no'
|
s943752827 | p02271 | u177808190 | 1452654211 | Python | Python | py | Runtime Error | 0 | 0 | 336 | num_n = raw_input()
ele_n = raw_input()
num_m = raw_input()
ele_m = raw_input()
n = ele_n.split()
m = ele_m.split()
for i in range(int(num_n) - 1):
for j in range(2 ** (int(num_m) - 1)):
sum[j] = 0
sum[j] += m[j]
sum += m[j]
if n[i] == sum:
print "yes"
break
print "no" |
s984827682 | p02271 | u655651061 | 1452690354 | Python | Python | py | Runtime Error | 0 | 0 | 267 | n1 = input()
A = map(int, raw_input().split())
n2 = input()
q = map(int, raw_input().split())
list = set()
for i in range(n1):
for j in range(n2):
if i != j:
list.add( A[i] + A[j] )
for i in range(n2):
if q[i] in list:
print "yes"
else:
print "no" |
s778087346 | p02271 | u613805578 | 1452702201 | Python | Python | py | Runtime Error | 0 | 0 | 309 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return true
if i >= n and m > sum(A)
return false
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for m in M
if res = solve(0,m):
print 'yes'
else:
print 'no' |
s700599602 | p02271 | u613805578 | 1452702220 | Python | Python | py | Runtime Error | 0 | 0 | 309 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n and m > sum(A)
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for m in M
if res = solve(0,m):
print 'yes'
else:
print 'no' |
s493455504 | p02271 | u613805578 | 1452702248 | Python | Python | py | Runtime Error | 0 | 0 | 315 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n and m > sum(A)
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for m in M
if res = solve(0,m):
print 'yes'
else:
print 'no' |
s657327284 | p02271 | u613805578 | 1452702284 | Python | Python | py | Runtime Error | 0 | 0 | 309 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n and m > sum(A)
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' |
s904916356 | p02271 | u613805578 | 1452702310 | Python | Python | py | Runtime Error | 0 | 0 | 310 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n and m > sum(A):
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' |
s891073076 | p02271 | u613805578 | 1452702502 | Python | Python | py | Runtime Error | 0 | 0 | 309 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n or m > sum(A):
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" |
s362906935 | p02271 | u613805578 | 1452702872 | Python | Python | py | Runtime Error | 0 | 0 | 310 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n or m > sum(A):
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' |
s219838916 | p02271 | u613805578 | 1452702891 | Python | Python | py | Runtime Error | 0 | 0 | 310 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n or m > sum(A):
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" |
s357838179 | p02271 | u613805578 | 1452702943 | Python | Python | py | Runtime Error | 0 | 0 | 306 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n or m > sum(A):
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" |
s155579645 | p02271 | u613805578 | 1452702967 | Python | Python | py | Runtime Error | 0 | 0 | 302 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n or m > sum(A):
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" |
s037491554 | p02271 | u613805578 | 1452702973 | Python | Python | py | Runtime Error | 0 | 0 | 304 | n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n or m > sum(A):
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" |
s865673095 | p02271 | u885889402 | 1452706938 | Python | Python3 | py | Runtime Error | 0 | 0 | 529 | def check(m,g,A,n):
for i in range(n):
gg = g + A[n-i-1]
if m == gg:
return True
elif n == 0 or m < gg:
continue
if check(m,gg,A,n-i-1) == True:
return True
return False
n=int(input())
A=list(map(int,str.split(input())))
q = int(input())
m=list(map(int,str.split(input())))
mini = min(A)
nor = sum(A)
for mi in m:
if mi < mini or mi > nor:
print(no)
if check(mi,0,A,n):
print("yes")
else:
print("no") |
s531619799 | p02271 | u724923896 | 1452831592 | Python | Python | py | Runtime Error | 0 | 0 | 332 | n = input()
A = map(int, input().split())
q = input()
m = map(int, input().split())
def solve(i, m):
if i == m:
return true
if i > n:
return false
res = solve(i + 1, m) || solve(i + 1, m - A[i])
return res
for j in range(0, q-1):
if m == solve(i + 1, m) || solve(i + 1, m - A[i]):
print "yes"
else:
print "no" |
s641465652 | p02271 | u724923896 | 1452832042 | Python | Python | py | Runtime Error | 0 | 0 | 305 | n = input()
A = map(int, input().split())
q = input()
m = map(int, input().split())
def solve(i, m):
if i == m:
return true
if i > n:
return false
res = solve(i + 1, m) || solve(i + 1, m - A[i])
return res
for j in range(0, q-1):
if m == solve(j, m(j)):
print "yes"
else:
print "no" |
s799054178 | p02271 | u724923896 | 1452832241 | Python | Python | py | Runtime Error | 0 | 0 | 300 | n = input()
A = map(int, input().split())
q = input()
m = map(int, input().split())
def solve(i, m):
if i == m:
return true
if i > n:
return false
res = solve(i + 1, m) || solve(i + 1, m - A[i])
return res
for j in range(0, q-1):
if m == solve(j, m(j)):
print "yes"
else:
print "no" |
s830036169 | p02271 | u724923896 | 1452832289 | Python | Python | py | Runtime Error | 0 | 0 | 312 | n = input()
A = map(int, input().split())
q = input()
m = map(int, input().split())
def solve(i, m):
if i == m:
return true
if i > n:
return false
res = solve(i + 1, m) || solve(i + 1, m - A[i])
return res
for j in range(0, q-1):
if m == solve(j, m(j)):
print "yes"
else:
print "no" |
s553442941 | p02271 | u724923896 | 1452832360 | Python | Python | py | Runtime Error | 0 | 0 | 310 | n = input()
A = map(int, input().split())
q = input()
m = map(int, input().split())
def solve(i, m):
if i == m:
return true
if i > n:
return false
res = solve(i + 1, m) || solve(i + 1, m - A(i))
return res
for j in range(0, q):
if m == solve(j, m(j)):
print "yes"
else:
print "no" |
s707610872 | p02271 | u724923896 | 1452832579 | Python | Python | py | Runtime Error | 0 | 0 | 316 | n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())
def solve(i, m):
if i == m:
return true
if i > n:
return false
res = solve(i + 1, m) || solve(i + 1, m - A(i))
return res
for j in range(0, q-1):
if m == solve(0, m(j)):
print "yes"
else:
print "no" |
s935859506 | p02271 | u724923896 | 1452832628 | Python | Python | py | Runtime Error | 0 | 0 | 315 | n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())
def solve(i, m):
if i == m:
return true
if i > n:
return false
res = solve(i + 1, m) || solve(i + 1, m - A(i))
return res
for j in range(0, q-1):
if m == solve(j, m(j)):
print "yes"
else:
print "no" |
s093532275 | p02271 | u724923896 | 1452832689 | Python | Python | py | Runtime Error | 0 | 0 | 313 | n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())
def solve(i, m):
if i == m:
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(0, q):
if m == solve(0, m(j)):
print "yes"
else:
print "no" |
s757698570 | p02271 | u724923896 | 1452832815 | Python | Python | py | Runtime Error | 0 | 0 | 343 | n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())
??
def solve(i, m):
??if m == 0:
????return true
??if i >= n and m > 0:
????return false
??res = solve(i + 1, m) or solve(i + 1, m - A(i))
??return res
????
for j in range(0, q):
??if m == solve(0, m(j)):
????print "yes"
??else:
????print "no" |
s735300905 | p02271 | u724923896 | 1452832886 | Python | Python | py | Runtime Error | 0 | 0 | 323 | n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return true
if i >= n and m > 0:
return false
res = solve(i + 1, m) or solve(i + 1, m - A(i))
return res
for j in range(0, q):
if m == solve(0, m(j)):
print "yes"
else:
print "no" |
s430168674 | p02271 | u724923896 | 1452833130 | Python | Python | py | Runtime Error | 0 | 0 | 300 | n = input()
A = map(int, raw_input().split())
q = input()
m = map(int, raw_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(0, q):
if solve(0, m(j)):
print "yes"
else:
print "no" |
s664261360 | p02271 | u724923896 | 1452833308 | Python | Python | py | Runtime Error | 0 | 0 | 323 | n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return true
if i >= n and m > 0:
return false
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for j in range(0, q):
if m == solve(0, m[j]):
print "yes"
else:
print "no" |
s470493075 | p02271 | u724923896 | 1452833523 | Python | Python | py | Runtime Error | 0 | 0 | 301 | n = raw_input()
A = map(int, raw_input().split())
q = raw_input()
m = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return 1
if i >= n:
return 0
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for j in range(0, q):
if solve(0, m[j]):
print "yes"
else:
print "no" |
s726073585 | p02271 | u724923896 | 1452833720 | Python | Python | py | Runtime Error | 0 | 0 | 317 | n = input()
A = map(int, raw_input().split())
q = input()
m = map(int, raw_input().split())
def solve(i, m):
if m == 0:
return True
if i >= n and m > sum(A):
return False
res = solve(i + 1, m) or solve(i + 1, m - A[i])
return res
for j in range(0, q-1):
if solve(0, m[j]):
print "yes"
else:
print "no" |
s389303258 | p02271 | u069446126 | 1452876460 | Python | Python | py | Runtime Error | 0 | 0 | 637 |
n = int(raw_input())
A = map(int, raw_input().split())
sorted(A)
q = int(raw_input())
M = map(int, raw_input().split())
sorted(M)
result = []
for i in range(q):
result.append('no ')
for i in range(n-1):
sum_n = A[i]
M_clone = M[:]
flag = False
for j in range(n-1-i):
if flag:
break
sum_n += A[i+1+j]
for k in range(len(M)):
if M_clone[k] == sum_n:
result[k] = 'yes '
M.pop(k)
flag = True
break
elif M_clone[k] < sum_n:
M_clone.pop(k)
for i in range(q):
print result[i] |
s174648572 | p02271 | u069446126 | 1452876682 | Python | Python | py | Runtime Error | 0 | 0 | 640 |
n = int(raw_input())
A = map(int, raw_input().split())
A.sort()
q = int(raw_input())
M = map(int, raw_input().split())
M.sort()
result = []
for i in range(q):
result.append('no')
for i in range(n-1):
sum_n = A[i]
M_clone = M[:]
flag = False
for j in range(n-1-i):
if flag:
break
sum_n = sum_n + A[i+1+j]
for k in range(len(M)):
if M_clone[k] == sum_n:
result[k] = 'yes'
M.pop(k)
flag = True
break
elif M_clone[k] < sum_n:
M_clone.pop(k)
for i in range(q):
print result[i] |
s231514672 | p02271 | u069446126 | 1452877537 | Python | Python | py | Runtime Error | 0 | 0 | 631 |
n = int(raw_input())
A = map(int, raw_input().split())
A.sort()
q = int(raw_input())
M = map(int, raw_input().split())
M.sort()
result = []
for i in range(q):
result.append('no')
for i in range(n-1):
sum_n = A[i]
M_clone = M[:]
flag = False
for j in range(n-1-i):
if flag:
break
sum_n = sum_n + A[i+1+j]
for k in range(len(M)):
if M_clone[k] == sum_n:
result[k] = 'yes'
M.pop(k)
flag = True
break
elif M_clone[k] < sum_n:
M_clone.pop(k)
for i in result:
print(i) |
s362302606 | p02271 | u824216249 | 1452926705 | Python | Python | py | Runtime Error | 0 | 0 | 393 | n = input()
A = map(int,raw_input().split())
q = input()
M = map(int,raw_input().split())
def tansaku(Mi,i):
if Mi == 0: return True
if i < n and min(A[i:] <= Mi <= sum(A[i:]):
r1 = tansaku(Mi-A[i],i+1) #Mi-A[i] == 0 ????????°???True
if r1: return r1
r2 = tansaku(Mi,i+1)
if r2: return r2
for Mi in M:
print "yes" if solve(Mi,0) else "no" |
s202954797 | p02271 | u069446126 | 1452936302 | Python | Python | py | Runtime Error | 0 | 0 | 445 |
n = int(raw_input())
A = map(int, raw_input().split())
q = int(raw_input())
M = map(int, raw_input().split())
result = []
for i in range(q):
result.append('no')
for i in range(n-1):
sum_n = A[i]
for j in range(n-1-i):
ad = A[i+1+j]
for k in range(n-2-j):
sum_n = sum_n + ad
ad = ad + A[i+j+2+k]
if M[k] == sum_n:
result[k] = 'yes'
for i in result:
print(i) |
s196647091 | p02271 | u069446126 | 1452941996 | Python | Python | py | Runtime Error | 0 | 0 | 502 | for i in range(n):
sum_n = A[i]
for j in range(q):
if M[j] == sum_n:
result[j] = 'yes'
for j in range(n-1-i):
sum_n = A[i]
ad = A[i+j+1]
sum_n = sum_n + ad
for k in range(q):
if M[k] == sum_n:
result[k] = 'yes'
for k in range(n-2-i-j):
ad = ad + A[i+j+2+k]
sum_n = sum_n + ad
for l in range(q):
if M[l] == sum_n:
result[l] = 'yes' |
s252011457 | p02271 | u619765879 | 1452962637 | Python | Python | py | Runtime Error | 0 | 0 | 433 | def solve(i, m):
if dp[i][m]==0 or dp[i][m]==1:
return dp[i][m]
if m == 0:
dp[i][m] = 1
elif i >= n:
dp[i][m] = 0
elif solve(i+1, m):
dp[i][m] = 1
elif solve(i+1, m-A[i]):
dp[i][m] = 1
else:
dp[i][m] = 0
return dp[i][m]
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(p):
if solve(0, m[i]):
print 'yes'
else:
print 'no' |
s780186561 | p02271 | u619765879 | 1452962676 | Python | Python | py | Runtime Error | 0 | 0 | 417 | def solve(i, m):
if dp[i][m]==1
return dp[i][m]
if m == 0:
dp[i][m] = 1
elif i >= n:
dp[i][m] = 0
elif solve(i+1, m):
dp[i][m] = 1
elif solve(i+1, m-A[i]):
dp[i][m] = 1
else:
dp[i][m] = 0
return dp[i][m]
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(p):
if solve(0, m[i]):
print 'yes'
else:
print 'no' |
s117216323 | p02271 | u619765879 | 1452962778 | Python | Python | py | Runtime Error | 0 | 0 | 479 | def solve(i, m):
if dp[i][m]!=-1
return dp[i][m]
if m == 0:
dp[i][m] = 1
elif i >= n:
dp[i][m] = 0
elif solve(i+1, m):
dp[i][m] = 1
elif solve(i+1, m-A[i]):
dp[i][m] = 1
else:
dp[i][m] = 0
return dp[i][m]
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(n):
for m in range(p):
dp[i][m] == -1
for i in range(p):
if solve(0, m[i]):
print 'yes'
else:
print 'no' |
s510800359 | p02271 | u619765879 | 1452962789 | Python | Python | py | Runtime Error | 0 | 0 | 485 | def solve(i, m):
if dp[i][m] is not -1
return dp[i][m]
if m == 0:
dp[i][m] = 1
elif i >= n:
dp[i][m] = 0
elif solve(i+1, m):
dp[i][m] = 1
elif solve(i+1, m-A[i]):
dp[i][m] = 1
else:
dp[i][m] = 0
return dp[i][m]
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(n):
for m in range(p):
dp[i][m] == -1
for i in range(p):
if solve(0, m[i]):
print 'yes'
else:
print 'no' |
s936718483 | p02271 | u619765879 | 1452962974 | Python | Python | py | Runtime Error | 0 | 0 | 482 | def solve(i, m):
if dp[i][m] != -1:
return dp[i][m]
if m == 0:
dp[i][m] = 1
elif i >= n:
dp[i][m] = 0
elif solve(i+1, m):
dp[i][m] = 1
elif solve(i+1, m-A[i]):
dp[i][m] = 1
else:
dp[i][m] = 0
return dp[i][m]
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
for i in range(n):
for m in range(p):
dp[i][m] == -1
for i in range(p):
if solve(0, m[i]):
print 'yes'
else:
print 'no' |
s768407857 | p02271 | u619765879 | 1452962997 | Python | Python | py | Runtime Error | 0 | 0 | 493 | def solve(i, m):
if dp[i][m] != -1:
return dp[i][m]
if m == 0:
dp[i][m] = 1
elif i >= n:
dp[i][m] = 0
elif solve(i+1, m):
dp[i][m] = 1
elif solve(i+1, m-A[i]):
dp[i][m] = 1
else:
dp[i][m] = 0
return dp[i][m]
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
dp = [][]
for i in range(n):
for m in range(p):
dp[i][m] == -1
for i in range(p):
if solve(0, m[i]):
print 'yes'
else:
print 'no' |
s543922373 | p02271 | u619765879 | 1452963038 | Python | Python | py | Runtime Error | 0 | 0 | 491 | def solve(i, m):
if dp[i][m] != -1:
return dp[i][m]
if m == 0:
dp[i][m] = 1
elif i >= n:
dp[i][m] = 0
elif solve(i+1, m):
dp[i][m] = 1
elif solve(i+1, m-A[i]):
dp[i][m] = 1
else:
dp[i][m] = 0
return dp[i][m]
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
dp = []
for i in range(n):
for m in range(p):
dp[i][m] == -1
for i in range(p):
if solve(0, m[i]):
print 'yes'
else:
print 'no' |
s428356250 | p02271 | u619765879 | 1452963161 | Python | Python | py | Runtime Error | 0 | 0 | 493 | def solve(i, m):
if dp[i][m] != -1:
return dp[i][m]
if m == 0:
dp[i][m] = 1
elif i >= n:
dp[i][m] = 0
elif solve(i+1, m):
dp[i][m] = 1
elif solve(i+1, m-A[i]):
dp[i][m] = 1
else:
dp[i][m] = 0
return dp[i][m]
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
dp = [[]]
for i in range(n):
for m in range(p):
dp[i][m] == -1
for i in range(p):
if solve(0, m[i]):
print 'yes'
else:
print 'no' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.