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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s771197177 | p03806 | u210440747 | 1486889371 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 604 | import numpy as np
if __name__=="__main__":
inputs_number = lambda : [int(x) for x in input().split()]
N, Ma, Mb = inputs_number()
drugs = [inputs_number() for i in range(N)]
inf = 100*N + 1
dp = np.ones((N+1,N*10+1,N*10+1)) * inf
dp[0,0,0] = 0.0
for i in range(N):
for ca in range(N*10+1):
for cb in range(N*10+1):
if(dp[i,ca,cb]==inf):
continue
dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]])
dp[i+1,ca+drugs[i][0],cb+drugs[i][1]]=np.min([dp[i+1,ca+drugs[i][0],cb+drugs[i][1]],dp[i,ca,cb]+drugs[i][2]]) |
s732445415 | p03806 | u210440747 | 1486889172 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 823 | import numpy as np
if __name__=="__main__":
inputs_number = lambda : [int(x) for x in input().split()]
N, Ma, Mb = inputs_number()
drugs = [inputs_number() for i in range(N)]
inf = 100*N + 1
dp = np.ones((N+1,N*10+1,N*10+1)) * inf
dp[0,0,0] = 0.0
for i in range(N):
for ca in range(N*10+1):
for cb in range(N*10+1):
if(dp[i,ca,cb]==inf):
continue
dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]])
dp[i+1,ca+drugs[i][0],cb+drugs[i][1]]=np.min([dp[i+1,ca+drugs[i][0],cb+drugs[i][1]],dp[i,ca,cb]+drugs[i][2]])
print(-1)
ans = inf
for ca in range(1, N*10+1):
for cb in range(1, N*10+1):
if(Ma*cb==Mb*ca and dp[N,ca,cb]<ans):
ans = dp[N,ca,cb]
if(ans==inf):
ans = -1
#print(int(ans))
|
s156283877 | p03806 | u210440747 | 1486888707 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 807 | import numpy as np
if __name__=="__main__":
inputs_number = lambda : [int(x) for x in input().split()]
N, Ma, Mb = inputs_number()
drugs = [inputs_number() for i in range(N)]
inf = 100*N + 1
dp = np.ones((N+1,N*10+1,N*10+1)) * inf
dp[0,0,0] = 0
for i in range(N):
for ca in range(N*10+1):
for cb in range(N*10+1):
if(dp[i,ca,cb]==inf):
continue
dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]])
dp[i+1,ca+drugs[i][0],cb+drugs[i][1]]=np.min([dp[i+1,ca+drugs[i][0],cb+drugs[i][1]],dp[i,ca,cb]+drugs[i][2]])
ans = inf
for ca in range(1, N*10+1):
for cb in range(1, N*10+1):
if(Ma*cb==Mb*ca and dp[N,ca,cb]<ans):
ans = dp[N,ca,cb]
if(ans==inf):
ans = -1
print(int(ans)) |
s725643527 | p03806 | u210440747 | 1486888511 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3192 | 786 | import numpy as np
if __name__=="__main__":
inputs_number = lambda : [int(x) for x in input().split()]
N, Ma, Mb = inputs_number()
drugs = [inputs_number() for i in range(N)]
inf = 100*N + 1
dp = np.ones((N+1,N*10+1,N*10+1)) * inf
dp[0,0,0] = 0
for i in range(N):
for ca in range(N*10+1):
for cb in range(N*10+1):
if(dp[i,ca,cb]==inf):
continue
dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]]);
dp[i+1,ca+drugs[i][0],cb+drugs[i][1]]=np.min([dp[i+1,ca+drugs[i][0],cb+drugs[i][1]],dp[i,ca,cb]+drugs[i][2]]);
ans = inf
for ca in range(1, N*10+1):
for cb in range(1, N*10+1):
if(Ma*cb == Mb*ca and dp[N,ca,cb] < ans):
ans = dp[N,ca,cb]
if(ans==inf):
ans = -1
print(int(ans))
|
s050673175 | p03806 | u210440747 | 1486888317 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3192 | 807 | import numpy as np
if __name__=="__main__":
inputs_number = lambda : [int(x) for x in input().split()]
N, Ma, Mb = inputs_number()
drugs = np.array([inputs_number() for i in range(N)]).astype(np.int16)
inf = 100*N + 1
dp = np.ones((N+1,N*10+1,N*10+1)) * inf
dp[0,0,0] = 0
for i in range(N):
for ca in range(N*10+1):
for cb in range(N*10+1):
if(dp[i,ca,cb]==inf):
continue
dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]]);
dp[i+1,ca+drugs[i,0],cb+drugs[i,1]]=np.min([dp[i+1,ca+drugs[i,0],cb+drugs[i,1]],dp[i,ca,cb]+drugs[i,2]]);
ans = inf
for ca in range(1, N*10+1):
for cb in range(1, N*10+1):
if(Ma*cb == Mb*ca and dp[N,ca,cb] < ans):
ans = dp[N,ca,cb]
if(ans==inf):
ans = -1
print(int(ans)) |
s832428553 | p03806 | u210440747 | 1486887715 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 790 | import numpy as np
if __name__=="__main__":
inputs_number = lambda : [int(x) for x in input().split()]
N, Ma, Mb = inputs_number()
drugs = np.array([inputs_number() for i in range(N)])
inf = 100*N + 1
dp = np.ones((N+1,N*10+1,N*10+1)) * inf
dp[0,0,0] = 0
for i in range(N):
for ca in range(N*10+1):
for cb in range(N*10+1):
if(dp[i,ca,cb]==inf):
continue
dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]]);
dp[i+1,ca+drugs[i,0],cb+drugs[i,1]]=np.min([dp[i+1,ca+drugs[i,0],cb+drugs[i,1]],dp[i,ca,cb]+drugs[i,2]]);
ans = inf
for ca in range(1, N*10+1):
for cb in range(1, N*10+1):
if(Ma*cb == Mb*ca and dp[N,ca,cb] < ans):
ans = dp[N,ca,cb]
if(ans==inf):
ans = -1
print(int(ans)) |
s124397585 | p03806 | u210440747 | 1486887284 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 793 | import numpy as np
if __name__=="__main__":
inputs_number = lambda : [int(x) for x in input().split()]
N, Ma, Mb = inputs_number()
drugs = np.array([inputs_number() for i in range(N)])
inf = 100*N + 1
dp = np.ones((N+1,N*10+1,N*10+1)) * inf
dp[0,0,0] = 0
for i in range(0, N):
for ca in range(N*10+1):
for cb in range(N*10+1):
if(dp[i,ca,cb]==inf):
continue
dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]]);
dp[i+1,ca+drugs[i,0],cb+drugs[i,1]]=np.min([dp[i+1,ca+drugs[i,0],cb+drugs[i,1]],dp[i,ca,cb]+drugs[i,2]]);
ans = inf
for ca in range(1, N*10+1):
for cb in range(1, N*10+1):
if(Ma*cb == Mb*ca and dp[i,ca,cb] < ans):
ans = dp[i,ca,cb]
if(ans==inf):
ans = -1
print(int(ans)) |
s020458576 | p03806 | u210440747 | 1486886929 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 812 | import numpy as np
if __name__=="__main__":
inputs_number = lambda : [int(x) for x in input().split()]
N, Ma, Mb = inputs_number()
drugs = np.array([inputs_number() for i in range(N)])
inf = 100*N + 1
dp = np.ones((N,N*10,N*10)) * inf
dp[0,0,0] = 0
for i in range(0, N-1):
for ca in range(N*10):
for cb in range(N*10):
if(dp[i,ca,cb]==inf):
continue
dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]]);
dp[i+1,ca+drugs[i,0],cb+drugs[i,1]]=np.min([dp[i+1,ca+drugs[i,0],cb+drugs[i,1]],dp[i,ca,cb]+drugs[i,2]]);
ans = inf
for i in range(1, N):
for ca in range(1, N*10):
for cb in range(1, N*10):
if(Ma*cb == Mb*ca and dp[i,ca,cb] < ans):
ans = dp[i,ca,cb]
if(ans==inf):
ans = -1
print(int(ans)) |
s171553571 | p03806 | u210440747 | 1486886804 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 815 | import numpy as np
if __name__=="__main__":
inputs_number = lambda : [int(x) for x in input().split(" ")]
N, Ma, Mb = inputs_number()
drugs = np.array([inputs_number() for i in range(N)])
inf = 100*N + 1
dp = np.ones((N,N*10,N*10)) * inf
dp[0,0,0] = 0
for i in range(0, N-1):
for ca in range(N*10):
for cb in range(N*10):
if(dp[i,ca,cb]==inf):
continue
dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]]);
dp[i+1,ca+drugs[i,0],cb+drugs[i,1]]=np.min([dp[i+1,ca+drugs[i,0],cb+drugs[i,1]],dp[i,ca,cb]+drugs[i,2]]);
ans = inf
for i in range(1, N):
for ca in range(1, N*10):
for cb in range(1, N*10):
if(Ma*cb == Mb*ca and dp[i,ca,cb] < ans):
ans = dp[i,ca,cb]
if(ans==inf):
ans = -1
print(int(ans)) |
s884944992 | p03806 | u210440747 | 1486886239 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 903 | import numpy as np
if __name__=="__main__":
inputs_number = lambda : [int(x) for x in input().replace("\n", "").split(" ")]
N, Ma, Mb = inputs_number()
drugs = np.array([inputs_number() for i in range(N)])
inf = 100*N + 1
dp = np.ones((N,N*10,N*10)) * inf
dp[0,0,0] = 0
for i in range(0, N-1):
for ca in range(N*10):
for cb in range(N*10):
if(dp[i,ca,cb]==inf):
continue
dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]]);
dp[i+1,ca+drugs[i,0],cb+drugs[i,1]]=np.min([dp[i+1,ca+drugs[i,0],cb+drugs[i,1]],dp[i,ca,cb]+drugs[i,2]]);
ans = inf
for i in range(1, N):
for ca in range(1, N*10):
for cb in range(1, N*10):
if(Ma*cb == Mb*ca and dp[i,ca,cb] < ans):
ans = dp[i,ca,cb]
if(ans==inf):
ans = -1
print(int(ans)) |
s497589518 | p03806 | u210440747 | 1486886069 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 906 | import numpy as np
if __name__=="__main__":
inputs_number = lambda : [int(x) for x in input().replace("\n", "").split(" ")]
N, Ma, Mb = inputs_number()
drugs = np.array([inputs_number() for i in range(N)])
inf = 100*N + 1
dp = np.ones((N,N*10,N*10)) * inf
dp[0,0,0] = 0
for i in range(0, N-1):
for ca in range(N*10):
for cb in range(N*10):
if(dp[i,ca,cb]==inf):
continue
dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]]);
dp[i+1,ca+drugs[i,0],cb+drugs[i,1]]=np.min([dp[i+1,ca+drugs[i,0],cb+drugs[i,1]],dp[i,ca,cb]+drugs[i,2]]);
ans = inf
for i in range(1, N):
for ca in range(1, N*10):
for cb in range(1, N*10):
if(Ma*cb == Mb*ca and dp[i,ca,cb] < ans):
ans = dp[i,ca,cb]
if(ans == inf):
ans = -1
print(int(ans))
|
s844304641 | p03806 | u314057689 | 1486873095 | Python | Python (3.4.3) | py | Runtime Error | 47 | 5228 | 1115 | from copy import deepcopy as dcopy
import fractions
def main():
global N, ma, mb
N, ma, mb = map(int, input().split())
shop = [list(map(int, input().split())) for n in range(N)]
status = dd(int)
status[(0,0)] = 0
minimum = 100000
for product in shop:
# buy
old_status = dcopy(status)
for s, v in old_status.items():
key = (s[0]+product[0], s[1]+product[1])
value = v + product[2]
if not key in status:
status[key] = value
if check(key) and value < minimum:
minimum = value
elif status[key] > value:
status[key] = value
if check(key) and value < minimum:
minimum = value
if minimum == 100000:
print(-1)
else:
print(minimum)
def check(key):
c = fractions.gcd(key[0], key[1])
if key[0]/c == ma and key[1]/c == mb:
return True
else:
return False
if __name__ == "__main__":# {{{
try:
import test
test.test()
except:
main()# }}}
|
s330991838 | p03806 | u583826716 | 1486871086 | Python | Python (3.4.3) | py | Runtime Error | 29 | 3540 | 1306 | from copy import deepcopy
fin = open('test4.txt')
input = fin.readline
def wfs(tree, root, node_num):
lost_list = [root]
def _wfs(tree, root, lost_list) -> int:
if len(lost_list) == node_num:
return 1
counter = 0
for i in tree[root]:
if i not in lost_list:
tmp = deepcopy(lost_list)
tmp.append(i)
counter += _wfs(tree, i, tmp)
return counter
return _wfs(tree, 0, lost_list)
N, MA, MB = [int(i) for i in input().rstrip().split()]
TGT = MA / MB
med = [[int(i) for i in input().rstrip().split()] for _ in range(N)]
flag_list = [0] * N
amount = [0, 0]
all_list = list()
def solve(amount, flag_list, money, i):
global TGT
global all_list
global med
global N
try :
if amount[0] / amount[1] == TGT:
all_list.append(money)
except ZeroDivisionError as e:
pass
if i == N:
return
solve(amount, flag_list, money, i + 1)
flag_list[i] = 1
amount[0] += med[i][0]
amount[1] += med[i][1]
solve(amount, flag_list, money + med[i][2], i + 1)
flag_list[i] = 0
amount[0] -= med[i][0]
amount[1] -= med[i][1]
solve(amount, flag_list, 0, 0)
if len(all_list) == 0:
print(-1)
else:
print(min(all_list)) |
s080951486 | p03806 | u332385682 | 1486870713 | Python | PyPy3 (2.4.0) | py | Runtime Error | 184 | 38384 | 1638 | import sys
def debug(x, table):
for name, val in table.items():
if x is val:
print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
return None
def solve():
N, Ma, Mb = map(int, input().split())
a_w = []
b_w = []
costs = []
for i in range(N):
a, b, c = map(int, input().split())
a_w.append(a)
b_w.append(b)
costs.append(c)
dp = [[[-1]*(10*N + 1) for j in range(10*N + 1)]
for k in range(2)]
dp[0][0][0] = 0
dp[1][0][0] = 0
for i in range(N):
for a in range(10*N + 1):
for b in range(10*N + 1):
if a - a_w[i] >= 0 and b - b_w[i] >= 0:
if dp[0][a - a_w[i]][b - b_w[i]] >= 0:
if dp[1][a][b] == -1:
dp[1][a][b]= dp[0][a - a_w[i]][b - b_w[i]] + costs[i]
else:
min_ = min(dp[1][a][b],
dp[0][a - a_w[i]][b - b_w[i]] + costs[i])
dp[1][a][b] = min_
for k in range(10*N + 1):
dp[0][k] = dp[1][k][:]
for i in range(10*N + 1):
# print(*dp[0][i], file=sys.stderr)
min_cost = float('inf')
for a in range(10*N + 1):
for b in range(10*N + 1):
if a != 0 and b != 0:
if a * Mb == b * Ma and dp[1][a][b] > 0:
min_cost = min(min_cost, dp[1][a][b])
if min_cost == float('inf'):
ans = -1
else:
ans = min_cost
print(ans)
if __name__ == '__main__':
solve() |
s429911119 | p03806 | u402629484 | 1486869588 | Python | Python (3.4.3) | py | Runtime Error | 79 | 4120 | 756 | Unknown = 1234567
best = Unknown
N, A, B = map(int, input().split())
abc = []
for _ in range(N):
abc.append(list(map(int, input().split())))
def search(choice, a, b, c):
if a % A == b % B == 0 and a // A == b // B:
global best
best = min(best, c)
choice.pop()
return
for i in range(N):
if i in choice:
continue
if (a / b > A / B and abc[i][0] < abc[i][1]) or (a / b < A / B and abc[i][0] > abc[i][1]):
if best <= c + abc[i][2]:
return
search(choice, a + abc[i][0], b + abc[i][1], c + abc[i][2])
choice.pop()
for i in range(N):
search([i], abc[i][0], abc[i][1], abc[i][2])
if best == Unknown:
best = -1
print(best)
|
s661714904 | p03806 | u985443069 | 1486869356 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 673 |
n, ma, mb = map(int, input().split())
a = [0] * n
b = [0] * n
c = [0] * n
for i in range(n):
a[i], b[i], c[i] = map(int, input().split())
M = 401
INF = 10 ** 15
min_cost = dict()
min_cost[0, 0] = 0
for k in range(n):
keys = min_cost.keys()
for i, j in reversed(sorted(keys)):
if i + a[k] < M and j + b[k] < M:
cc = min_cost[i][j] + c[k]
if cc < min_cost[i + a[k]][j + b[k]]:
min_cost[i + a[k]][j + b[k]] = cc
res = INF
for i in range(1, M):
for j in range(1, M):
if i * mb == j * ma:
if min_cost[i][j] < res:
res = min_cost[i][j]
if res == INF:
res = -1
print(res) |
s318304867 | p03806 | u332385682 | 1486868174 | Python | PyPy3 (2.4.0) | py | Runtime Error | 187 | 41968 | 1231 | import sys
def debug(x, table):
for name, val in table.items():
if x is val:
print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
return None
def solve():
N, Ma, Mb = map(int, input().split())
a_w = []
b_w = []
costs = []
for i in range(N):
a, b, c = map(int, input().split())
a_w.append(a)
b_w.append(b)
costs.append(c)
dp = [[[-1]*(10*N + 1) for j in range(10*N + 1)]
for k in range(2)]
dp[0][0][0] = 0
for i in range(N):
for a in range(10*N + 1):
for b in range(10*N + 1):
if a - a_w[i] >= 0 and b - b_w[i] >= 0:
if dp[0][a - a_w[i]][b - b_w[i]] >= 0:
dp[1][a][b]= dp[0][a - a_w[i]][b - b_w[i]] + costs[i]
dp[0] = dp[1].copy()
# debug(dp, locals())
min_cost = float('inf')
for a in range(10*N + 1):
for b in range(10*N + 1):
if a * Mb == b * Ma:
if dp[1][a][b] != -1:
min_cost = min(min_cost, dp[1][a][b])
if min_cost == float('inf'):
ans = -1
else:
ans = min_cost
print(ans)
if __name__ == '__main__':
solve() |
s389781930 | p03806 | u596276291 | 1486866729 | Python | Python (3.4.3) | py | Runtime Error | 253 | 7392 | 820 | from collections import defaultdict
from fractions import Fraction
memo = {}
gl_ans = 10 ** 10
def dfs(i, a, b, c):
global gl_ans
if a != 0 and b != 0 and Fraction(a, b) == Fraction(Ma, Mb):
gl_ans = min(gl_ans, c)
return c
if i == N:
return 10 ** 10
if (i, a, b, c) in memo:
return memo[(i, a, b)]
if c > gl_ans:
return 10 ** 10
ans = dfs(i + 1, a + l[i][0], b + l[i][1], c + l[i][2])
ans = min(ans, dfs(i + 1, a, b, c))
memo[(i, a, b, c)] = ans
return ans
if __name__ == '__main__':
N, Ma, Mb = map(int, input().split())
l = []
for _ in range(N):
a, b, c = map(int, input().split())
l.append((a, b, c))
s = dfs(0, 0, 0, 0)
if s >= 10 ** 10:
print(-1)
else:
print(s)
|
s610322490 | p03807 | u481250941 | 1597695990 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9020 | 1033 | #
# agc010 a
#
import sys
from io import StringIO
import unittest
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """3
1 2 3"""
output = """YES"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """5
1 2 3 4 5"""
output = """NO"""
self.assertIO(input, output)
def resolve():
N = int(input())
A = list(map(int, input().split()))
e = 0
o = 0
for a in A:
if a % 2 == 0:
e += 1
else:
o += 1
if o % 2 == 0:
if (o // 2 + e) % 2 == 0:
print("YES")
else:
print("NO")
if __name__ == "__main__":
# unittest.main()
resolve()
|
s340659862 | p03807 | u350093546 | 1597159519 | Python | Python (3.8.2) | py | Runtime Error | 23 | 8984 | 145 | n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in a:
if i%2=1:
cnt+=1
if cnt%2==1:
print('NO')
else:
print('YES') |
s766704810 | p03807 | u754022296 | 1594688415 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9000 | 33 | [NO][YES]?k2?K[1-d0<G+]dsGx0k3|Rp |
s631445449 | p03807 | u350093546 | 1593061618 | Python | Python (3.8.2) | py | Runtime Error | 56 | 20104 | 139 | n=int(input())
a=list(map(int,input().split()))
a=[i if i%2==1 else None for i in a]
if a.count()%2==1:
print('NO')
else:
print('YES') |
s303538674 | p03807 | u760636024 | 1591348895 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38256 | 103 | N = int(input())
A = list(map(int, input().split())
if sum(A)%2:
print("NO")
else:
print("YES") |
s772586523 | p03807 | u760636024 | 1591348835 | Python | PyPy3 (2.4.0) | py | Runtime Error | 242 | 112396 | 86 | N = int(input())
A = list(input())
if sum(A)%2:
print("NO")
else:
print("YES") |
s748853176 | p03807 | u987164499 | 1591137067 | Python | Python (3.4.3) | py | Runtime Error | 51 | 14108 | 152 | n = int(input())
a = list(map(int,input().split()))
ki = [sum(1 for i in a if i%2 == 1)]
gu = n-ki
if gu == ki:
print("YES")
else:
print("NO") |
s167346987 | p03807 | u970809473 | 1590198423 | Python | Python (3.4.3) | py | Runtime Error | 19 | 5028 | 233 | n=int(input())
a=list(map(int,input()))
odd=0
even=0
for i in range(n):
if a[i]%2 == 0:
even += 1
else:
odd += 1
if odd % 2 == 0:
if (even + odd//2) % 2 == 0:
print('YES')
else:
print('NO')
else:
print('NO') |
s884145627 | p03807 | u691266554 | 1589833681 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 29 | python "test old competition" |
s312604107 | p03807 | u178079174 | 1589646890 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 158 | A = list(map(int,input().split()))
AA = sum([i%2 for i in A])
if N == 1:
print('YES')
exit()
if AA % 2 == 1:
print('NO')
exit()
print('YES')
|
s479125292 | p03807 | u980205854 | 1589415526 | Python | Python (3.4.3) | py | Runtime Error | 42 | 14104 | 158 | # A - Addition
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
k = (A[i] + k) % 2
k *= int(N!=1)
ans = ['YES', 'NO']
print(ans[k]) |
s252160566 | p03807 | u980205854 | 1589415275 | Python | Python (3.4.3) | py | Runtime Error | 24 | 5028 | 136 | # A - Addition
N = int(input())
k = 0
for i in range(N):
k = (int(input()) + k) % 2
k *= int(N!=1)
ans = ['YES', 'NO']
print(ans[k]) |
s571789569 | p03807 | u126844573 | 1588133748 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 143 | a, b, c = sorted(list(map(int, input().split())))
count = (b - a) // 2
count += 2 if (a + count * 2) != b else 0
count += c - b
print(count)
|
s166157361 | p03807 | u867826040 | 1587588591 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 106 | n=int(input().split())
a=list(map(int,input().split()))
if sum(a)%2==0:
print("YES")
else:
print("NO") |
s653553391 | p03807 | u867826040 | 1587588286 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 103 | n = int(input())
a = list(map(int,input().split()))
if len(a)%3 == 0
print("YES")
else:
print("NO") |
s802764843 | p03807 | u496511996 | 1586200269 | Python | Python (3.4.3) | py | Runtime Error | 42 | 14108 | 150 | n = input()
s = list(map(int,input().split()))
c = 0
for i in s:
if s % 2 == 1:
c+=1
if c % 2 == 1:
print("NO")
else:
print("YES") |
s604307249 | p03807 | u496511996 | 1586200237 | Python | Python (3.4.3) | py | Runtime Error | 42 | 14104 | 140 | n = input()
s = list(map(int,input().split()))
c = 0
for i in s:
if s % 2 == 1:
c+=1
if c % 2 == 1:
print("NO")
else:
print("YES") |
s525020669 | p03807 | u626467464 | 1585975381 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 11 | 5
1 2 3 4 5 |
s275995108 | p03807 | u835924161 | 1582117147 | Python | Python (3.4.3) | py | Runtime Error | 26 | 5032 | 146 | n=int(input())
co=int(0)
for i in range(n):
now=int(input())
if now%2==1:
co+=1
if co%2==1:
print("NO")
else:
print("YES") |
s346658837 | p03807 | u527993431 | 1582115614 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 147 | N=int(input())
L=list(map(int,input().split()))
count=0
for i in range N:
if L[i]%2==1:
count+=1
if count%2==1:
print("NO")
else:
print("YES") |
s162022463 | p03807 | u404290207 | 1581224960 | Python | PyPy3 (2.4.0) | py | Runtime Error | 294 | 81132 | 1284 | import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]
#本当に貪欲法か? DP法では??
#本当に貪欲法か? DP法では??
#本当に貪欲法か? DP法では??
n=ii()
arr=mii()
cnt=0
for i in range(n):
if arr[i]%2==1:
cnt+=1
if cnt%2==1:
print("NO")
else:
print("YES")
|
s642536690 | p03807 | u404290207 | 1581224922 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38512 | 1282 | import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]
#本当に貪欲法か? DP法では??
#本当に貪欲法か? DP法では??
#本当に貪欲法か? DP法では??
n=ii()
arr=mii()
cnt=0
for i in range(n):
if arr[i]%2=1:
cnt+=1
if cnt%2=1:
print("NO")
else:
print("YES")
|
s298786317 | p03807 | u469700628 | 1580360026 | Python | Python (3.4.3) | py | Runtime Error | 73 | 14364 | 339 | N = int(input())
numbers = list(map(int, input().split()))
odds = list(filter(lambda x: x % 2 == 0, numbers))
evens = list(filter(lambda x: x % 2 == 1, numbers))
evens_from_odds = sum(divmod(odds, 2))
odds_from_evens = sum(divmod(evens, 2))
if odds_from_evens % 2 == 1 or evens_from_odds % 2 == 1:
print("YES")
else:
print("NO") |
s867792286 | p03807 | u814986259 | 1580218726 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 163 | N=int(input())
A=list(map(),int.input().split())
count=0
for i in range(N):
if A[i]%2==1:
count+=1
ans=["YES","NO"]
print(ans[count%2])
|
s465141546 | p03807 | u328510800 | 1580171606 | Python | Python (3.4.3) | py | Runtime Error | 43 | 14112 | 125 | input()
a = list(map(int, input().split()))
l = len(filter(lambda x : x & 1, a))
if l & 1:
print("NO")
else:
print("YES") |
s329331565 | p03807 | u423585790 | 1578084869 | Python | PyPy3 (2.4.0) | py | Runtime Error | 230 | 59120 | 1076 | #!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
#solve
def solve():
n = II()
a = LI()
print("NO" if sum(map(lambda x: x[0] & 1, a)) & 1 else "YES")
return
#main
if __name__ == '__main__':
solve()
|
s754721803 | p03807 | u423585790 | 1578084862 | Python | PyPy3 (2.4.0) | py | Runtime Error | 221 | 59248 | 1076 | #!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
#solve
def solve():
n = II()
a = LI()
print("NO" if sum(map(lambda x: x[0] & 1, a)) & 1 else "YES")
return
#main
if __name__ == '__main__':
solve()
|
s561646327 | p03807 | u487594898 | 1577666812 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 136 | N = input()
A = input().split()
count=0
for i in range(N):
if A[i]%2==1:
count+=1
if conut%2=1:
print("NO")
else:
print("YES") |
s313397763 | p03807 | u187109555 | 1574544696 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 667 | _ = input()
As = [int(x) for x in input().split()]
even_pair_count = 0
odd_pair_count = 0
even_pair = []
odd_pair = []
for a in As:
if a%2 == 0:
even_pair.append(1)
if len(even_pair) == 2:
even_pair = []
even_pair_count += 1
else:
odd_pair.append(1)
if len(odd_pair) == 2:
odd_pair = []
odd_pair_count += 1
pair_num = even_pair_count + odd_pair_count
rest_num = len(even_pair) + len(odd_pair)
# print(pair_num)
# print(rest_num)
elif rest_num == 2:
print("NO")
if pair_num == 1:
print("YES")
elif (pair_num+rest_num) % 2 == 0:
print("YES")
else:
print("NO") |
s809258083 | p03807 | u846634344 | 1573847383 | Python | Python (3.4.3) | py | Runtime Error | 51 | 14108 | 122 | n = int(input())
a = [int(x) for x in input().split()]
odds = [i for i in a if 2%i]
print("No" if 2%len(odds) else "Yes") |
s283926320 | p03807 | u727787724 | 1573808442 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 151 | n=int(input())
a=list(map(int.input().split()))
c=0
for i in range(n):
if a[i]%2!=0:
c+=1
if c%2==0:
print('YES')
else:
print('NO') |
s525048487 | p03807 | u703890795 | 1567043071 | Python | Python (3.4.3) | py | Runtime Error | 19 | 5028 | 96 | N = input()
A = list(map(int, input()))
s = sum(A)
if s%2==0:
print("YES")
else:
print("NO") |
s432386761 | p03807 | u223646582 | 1562881020 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 161 | N = int(input())
A = [int(i) for i in input().split()]
c = 0
for a in A:
if a % 2 = 1:
c += 1
if c % 2 == 0:
print('YES')
else:
print('NO')
|
s153078407 | p03807 | u633914031 | 1562876094 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 134 | N=int(input())
A=list(map(int,input().split())
kazu = len([x for x in A if x%2 == 1])
if kazu%2==1:
print('NO')
else:
print('YES') |
s351218900 | p03807 | u391731808 | 1562674842 | Python | Python (3.4.3) | py | Runtime Error | 19 | 5028 | 50 | input()
print("YNEOS"[sum(map(int,input()))%2::2]) |
s101931306 | p03807 | u539517139 | 1561500304 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 123 | n=int(input())
a=list(map(int,input().split()))
s=0
for i in range(n):
s+=1 if a[i]%2==1
print('YES' if s%2==0 else 'NO') |
s476409464 | p03807 | u705378878 | 1560727468 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 708 | a = int(input())
b = input().split()
x = []
for i in b:
x.append(int(i))
count = 0
for i in x:
if i % 2 != 0:
count += 1
flag = 0
while True:
z = divmod(count,2)
#print(z)
if z[0] == 1:
break
if z[1] == 1:
flag = 1
break
count = z[0]
if flag == 1:
print("NO")
else:
print("YES")a = int(input())
b = input().split()
x = []
for i in b:
x.append(int(i))
count = 0
for i in x:
if i % 2 != 0:
count += 1
flag = 0
while True:
z = divmod(count,2)
#print(z)
if z[0] == 1:
break
if z[1] == 1:
flag = 1
break
count = z[0]
if flag == 1:
print("NO")
else:
print("YES") |
s507825896 | p03807 | u623687794 | 1560605799 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 173 | n=int(input())
odd=0
even=0
a=list(map(int,input().split()))
for i in range(n):
if a[i]%2=1:
odd+=1
else:
even+=1
if odd%2==1:
print("NO")
else:
print("YES") |
s361602990 | p03807 | u388415336 | 1559707817 | Python | Python (3.4.3) | py | Runtime Error | 46 | 14108 | 131 | num_ints = int(input())
sum_ints = sum([int(i) for i in input().split()])
if sum % 2 == 0:
print("YES")
else:
print("NO")
|
s638841962 | p03807 | u623819879 | 1559461794 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 88 | n=int(input())
a=sum([int(i) for i in input().split()]
print('YES' if a%2==0 else 'NO') |
s037113850 | p03807 | u854946179 | 1558652412 | Python | Python (3.4.3) | py | Runtime Error | 80 | 14108 | 240 | N=int(input())
A=list(map(int,input().split()))
Even = []
Odd = []
A.sort()
for a in A:
if a % 2 == 0:
a.append(Even)
if a % 2 == 1:
a.append(Odd)
if len(Odd) % 2 == 1:
print('NO')
else:
print('YES')
|
s931185108 | p03807 | u187205913 | 1557002745 | Python | Python (3.4.3) | py | Runtime Error | 63 | 14108 | 163 | n = int(input())
a = list(map(int,input().split()))
odd = 0
for i in range(n):
if a[i]%2==1:
odd+=1
if odd%2==0:
print('YES')
else:
pritn('NO') |
s740493431 | p03807 | u315485238 | 1555526690 | Python | Python (3.4.3) | py | Runtime Error | 50 | 14108 | 126 | N = int(input())
A = list(map(int, input().split()))
odd = [a for a in A if a%2]
if odd%2:
print('NO')
else:
print('YES') |
s889224622 | p03807 | u532099150 | 1554941716 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 104 | if __name__ == "__main__"
if (input() % 2) == 0
print ("NO")
else
print("YES")
|
s329350363 | p03807 | u532099150 | 1554941673 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 62 | if (input() % 2) == 0
print ("NO")
else
print("YES")
|
s013588731 | p03807 | u001687078 | 1554403828 | Python | Python (3.4.3) | py | Runtime Error | 41 | 14048 | 172 | import sys
sys.stdin.readline()
count = 0
a_list = list(map(int, sys.stdin.readline().split()))
for a in x_list:
count += a%2
print("YES") if count%2==0 else print("NO") |
s165841384 | p03807 | u001687078 | 1554401988 | Python | Python (3.4.3) | py | Runtime Error | 42 | 14052 | 177 | import sys
input_ = sys.stdin.readline
input_()
x_list = list(map(int, input_().split()))
for x in x_list:
if x%2==0:
a += 1
if a%2==0:
print("YES")
else:
print("NO") |
s152346153 | p03807 | u845333844 | 1551925822 | Python | Python (3.4.3) | py | Runtime Error | 46 | 14108 | 147 | n=int(input())
a=list(map(int,input().split()))
odd=0
for x in a:
if a%2==1:
odd+=1
if odd%2==1:
print('NO')
else:
print('YES') |
s445755941 | p03807 | u785578220 | 1550033238 | Python | Python (3.4.3) | py | Runtime Error | 42 | 14108 | 137 | a = int(input())
x= list(map(int, input().split()))
for i in x:
if i%2!=0:
s+=1
if s%2==0:
print("YES")
else:print("NO") |
s394043626 | p03807 | u375616706 | 1548866817 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 368 | N = int(input())
A = list(map(int, input().split()))
odd = len(list(filter(lambda x: x % 2 != 0, A)))
even = N - odd
ans = "YES"
if odd == 1 and even == 0:
odd = odd
elif odd % 2 == 1:
ans = "NO"
else:
even += odd//2
while True:
if even == 1:
if even % 2 == 1:
ans = "NO"
break
even //= 2
print(ans)
|
s604708039 | p03807 | u434208140 | 1547075655 | Python | Python (3.4.3) | py | Runtime Error | 64 | 11104 | 107 | f=lambda x:int(x)%2
n=int(input())
a=list(map(f,input().split())).count(1)
print([YNEOS][n>1 and a%2>0::2]) |
s188413361 | p03807 | u434208140 | 1547075420 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 106 | f=lambda x:int(x)%2
n=int(input())
a=list(map(f,input().split())).count(1)
print([YNEOS][n>1 and a%2>0::2] |
s253040347 | p03807 | u064408584 | 1540864188 | Python | Python (3.4.3) | py | Runtime Error | 51 | 14108 | 154 | n=int(input())
a=list(map(int, input().split()))
a=[i%2 for i in a]
b=a.count(1)
anb,b=a.count(0)+b//2,b+b//2
if an%2+b%2==1:print('YES')
else:print('NO') |
s531189086 | p03807 | u064408584 | 1540864074 | Python | Python (3.4.3) | py | Runtime Error | 52 | 14112 | 154 | n=int(input())
a=list(map(int, input().split()))
a=[i%2 for i in a]
b=a.count(1)
anb,b=a.count(0)+b//2,b+b//2
if an%2+b%2==1:print('YES')
else:print('NO') |
s175320437 | p03807 | u128914900 | 1540499109 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 131 | s=input().split()
i=0
count=0
while i<n:
if int(s[i])%2!=0:
count+=1
i+=1
if count%2==0:
print("Yes")
else:
print("No") |
s831629169 | p03807 | u457901067 | 1540055145 | Python | Python (3.4.3) | py | Runtime Error | 46 | 14360 | 159 | N = int(input())
A = list(map(int, input().split()))
cnt = 0
for x in A:
if A%2 == 1:
cnt += 1
if cnt % 2 == 0:
print("YES")
else:
print("NO") |
s073370693 | p03807 | u729133443 | 1538802720 | Python | Python (3.4.3) | py | Runtime Error | 117 | 58708 | 59 | input();print('YNEOS'[eval(input().replace(' ','^'))&1::2]) |
s998735114 | p03807 | u729133443 | 1538802650 | Python | Python (3.4.3) | py | Runtime Error | 113 | 58908 | 57 | input();print('YNEOS'[eval(input().replace(' ','^'))::2]) |
s866872831 | p03807 | u790301364 | 1537202387 | Python | Python (3.4.3) | py | Runtime Error | 53 | 15076 | 459 | def main10():
buf = int(input(""));
strbuf = input("");
strbufs = strbuf.split();
buf2 = [];
for i in range(buf):
buf2.append(int(strbufs[i]));
if len(buf2) == 1:
return("YES");
else:
ki = 0;
for i in range(buf):
if buf2 % 2 == 1:
ki += 1;
if ki % 2 == 0:
print("YES");
else:
print("NO");
if __name__ == '__main__':
main10() |
s019522387 | p03807 | u143492911 | 1521170268 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 479 | n=int(input())
a=list(map(int,input().split()))
even_cnt=0
odd_cnt=0
for i in a:
if i%2==0:
even_cnt+=1
else:
odd_cnt+=1
if 1<=odd_cnt:
even_cnt+=odd_cnt//2 #奇数から偶数になったもの数
odd_cnt=odd_cnt%2
even_cnt=even_cnt%2
if even_cnt==1 and odd_cnt==1:
print("NO")
else:
print("YES")
else:
print("YES")
#考察
#奇数の和も偶数の和も偶数なので、奇数の数を減らせばよい。
|
s210159326 | p03807 | u271456715 | 1489363562 | Python | Python (3.4.3) | py | Runtime Error | 69 | 14884 | 1079 | n = int(input().strip())
a = [int(x) for x in input().strip().split()]
flg = [-1 for i in range(n)]
b = []
l = [[] for i in range(n)]
for i in range(n - 1):
b.append([int(x) - 1 for x in input().strip().split()])
for x in b:
l[x[0]].append(x[1])
l[x[1]].append(x[0])
while True:
minimum = a[0]
idx = []
for i, x in enumerate(a):
if flg[i] != -1 or x > minimum:
continue
if x < minimum:
minimum = x
idx =[i]
else:
idx.append(i)
while True:
w = []
for i in idx:
flg[i] = 0
for x in l[i]:
if flg[x] == -1 and a[x] != a[i]:
flg[x] = 1
w.append(x)
idx = []
for i in w:
for x in l[i]:
if flg[x] == -1:
flg[x] = 0
for y in l[x]:
if flg[y] == -1 and a[x] > a[y]:
flg[x] = -1
break
if flg[x] == 0:
idx.append(x)
if len(idx) == 0:
break
if -1 not in flg:
break
sep = ''
s = ''
for i, x in enumerate(flg):
if x == 1:
s += sep + str(i + 1)
sep = ' '
print(s)
|
s907542564 | p03807 | u622568141 | 1489361205 | Python | Python (3.4.3) | py | Runtime Error | 148 | 19936 | 1343 | # -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10000)
def main():
# 入力処理
L1 = input()
L2 = input()
N = int(L1)
As = [int(x) for x in L2.split()]
print("N={}, As={}".format(N, As),
file=sys.stderr)
# アルゴリズム本体
even = [A % 2 == 0 for A in As]
N_even = sum(even)
N_odd = N - N_even
print("N_even:{}, N_odd:{}".format(N_even, N_odd),
file=sys.stderr)
results = list(explore(N_even, N_odd))
print(results,
file=sys.stderr)
# 出力
if any(results):
print('YES')
else:
print('NO')
def explore(N_even, N_odd):
# 再帰終了
if N_even in (0, 1) and N_odd in (0, 1):
if N_even == 0:
raise Exception("Unbelievable!!")
else:
if N_odd == 0:
yield True
else:
yield False
# もう1段潜る
else:
if N_even >= 2:
yield from explore(*process(N_even, N_odd, 'even'))
if N_odd >= 2:
yield from explore(*process(N_even, N_odd, 'odd'))
def process(N_even, N_odd, target):
# 1ターン分の処理
if target == 'even':
return N_even - 1, N_odd
elif target == 'odd':
return N_even + 1, N_odd - 2
if __name__ == '__main__':
main()
|
s191391322 | p03807 | u622568141 | 1489358148 | Python | Python (3.4.3) | py | Runtime Error | 143 | 15444 | 1313 | # -*- coding: utf-8 -*-
import sys
def main():
# 入力処理
L1 = input()
L2 = input()
N = int(L1)
As = [int(x) for x in L2.split()]
print("N={}, As={}".format(N, As),
file=sys.stderr)
# アルゴリズム本体
even = [A % 2 == 0 for A in As]
N_even = sum(even)
N_odd = N - N_even
print("N_even:{}, N_odd:{}".format(N_even, N_odd),
file=sys.stderr)
results = list(explore(N_even, N_odd))
print(results,
file=sys.stderr)
# 出力
if any(results):
print('YES')
else:
print('NO')
def explore(N_even, N_odd):
# 再帰終了
if N_even in (0, 1) and N_odd in (0, 1):
if N_even == 0:
raise Exception("Unbelievable!!")
else:
if N_odd == 0:
yield True
else:
yield False
# もう1段潜る
else:
if N_even >= 2:
yield from explore(*process(N_even, N_odd, 'even'))
if N_odd >= 2:
yield from explore(*process(N_even, N_odd, 'odd'))
def process(N_even, N_odd, target):
# 1ターン分の処理
if target == 'even':
return N_even - 1, N_odd
elif target == 'odd':
return N_even + 1, N_odd - 2
if __name__ == '__main__':
main() |
s589753321 | p03807 | u622568141 | 1489358038 | Python | Python (3.4.3) | py | Runtime Error | 143 | 15444 | 1313 | # -*- coding: utf-8 -*-
import sys
def main():
# 入力処理
L1 = input()
L2 = input()
N = int(L1)
As = [int(x) for x in L2.split()]
print("N={}, As={}".format(N, As),
file=sys.stderr)
# アルゴリズム本体
even = [A % 2 == 0 for A in As]
N_even = sum(even)
N_odd = N - N_even
print("N_even:{}, N_odd:{}".format(N_even, N_odd),
file=sys.stderr)
results = list(explore(N_even, N_odd))
print(results,
file=sys.stderr)
# 出力
if any(results):
print('YES')
else:
print('NO')
def explore(N_even, N_odd):
# 再帰終了
if N_even in (0, 1) and N_odd in (0, 1):
if N_even == 0:
raise Exception("Unbelievable!!")
else:
if N_odd == 0:
yield True
else:
yield False
# もう1段潜る
else:
if N_even >= 2:
yield from explore(*process(N_even, N_odd, 'even'))
if N_odd >= 2:
yield from explore(*process(N_even, N_odd, 'odd'))
def process(N_even, N_odd, target):
# 1ターン分の処理
if target == 'even':
return N_even - 1, N_odd
elif target == 'odd':
return N_even + 1, N_odd - 2
if __name__ == '__main__':
main() |
s621126028 | p03807 | u622568141 | 1489354786 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1210 | # -*- coding: utf-8 -*-
import sys
L1 = '3'
L2 = '1 2 3'
L1 = '5'
L2 = '1 2 3 4 5'
# L1, L2 = input()
def main():
N = int(L1)
As = map(int, L2.split())
even = [A % 2 == 0 for A in As]
N_even = sum(even)
N_odd = N - N_even
printerr("N={} (even:{}, odd:{})".format(N, N_even, N_odd))
results = list(explore(N_even, N_odd))
print(list(results))
if any(results):
print('YES')
else:
print('NO')
def explore(N_even, N_odd):
# 再帰終了
if N_even in (0, 1) and N_odd in (0, 1):
if N_even == 0:
raise Exception("Unbelievable!!")
else:
if N_odd == 0:
yield True
else:
yield False
# もう1段潜る
else:
if N_even >= 2:
yield from explore(*proc(N_even, N_odd, 'even'))
if N_odd >= 2:
yield from explore(*proc(N_even, N_odd, 'odd'))
def proc(N_even, N_odd, target):
if target == 'even':
return N_even - 1, N_odd
elif target == 'odd':
return N_even + 1, N_odd - 2
def printerr(*args, **kwargs):
print(*args, **kwargs, file=sys.stderr)
if __name__ == '__main__':
main()
|
s653667029 | p03807 | u692632484 | 1488408563 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 141 | N=int(input())
A=[int(i) for i in input().split()]
count=0
for i in A:
if i%2==1:
count+=1
if count%2==0:
print("YES")
else:
print("NO) |
s738014195 | p03807 | u319737087 | 1486644449 | Python | Python (3.4.3) | py | Runtime Error | 32 | 5032 | 165 | n = int(input())
arg_list = int(input())
k = 0
for item in arg_list:
if item % 2 == 1 :
k +=1
if k == 1:
print('YES')
else:
print('NO')
|
s719446520 | p03807 | u095902316 | 1486323877 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 389 | numInput = int(input())
amount = numInput
numOdd = int(numInput / 2) + (numInput % 2)
numEven 0 int(numInput / 2)
while True:
if amount >= 2:
if numOdd >= 2:
numOdd -= 2
numEven += 1
amount -= 1
else:
numEven -= 1
amount -= 1
else:
break
if amount == 1:
print('YES')
else:
print('NO')
|
s684824385 | p03807 | u558151813 | 1486293748 | Python | PyPy2 (5.6.0) | py | Runtime Error | 36 | 8816 | 160 | n = int(raw_input().split())
a = list(map(int, raw_input().split()))
p = map(lambda x : x % 2, a)
if p.count(1)%2 == 0 :
print "YES"
else :
print "NO" |
s929810347 | p03807 | u425351967 | 1486263161 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 178 | N = int(input())
A = [int(n) for n in input().split()]
cnt = 0
for in range(N):
if A[i] % 2 == 1:
cnt += 1
if cnt % 2 == 0:
print ('YES')
else:
print('NO')
|
s397461725 | p03807 | u720968399 | 1486262195 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 304 | import numpy as np
N = int(raw_input())
n = np.array(map(int, raw_input().split()))
Nsum = np.sum(n)
if not Nsum % np.cumsum(np.arange(N)):
print 'NO'
return
sa = n[1:-1] - n
for s in sa:
if s % n != Nsum / np.cumsum(np.arange(N)):
print 'NO'
return
print 'YES'
return |
s721457028 | p03807 | u583826716 | 1486261628 | Python | Python (3.4.3) | py | Runtime Error | 41 | 11232 | 110 | N = input()
if len([a for a in input().rstrip().split() if a % 2]) % 2:
print('NO')
else:
print('YES') |
s378857792 | p03807 | u125205981 | 1486261508 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3192 | 268 | def even(num):
if num & 1:
return('uneven')
else:
return('even')
N = int(input())
A = list(map(int, input().split()))
n = 0
for a in A:
if even(a) == 'uneven':
n += 1
if even(n) =a= 'even':
print('YES')
else:
print('NO')
|
s967947006 | p03807 | u123756661 | 1486260895 | Python | PyPy3 (2.4.0) | py | Runtime Error | 278 | 63216 | 114 | n=int(input())
a=[int(i) for i in input().split()]
od=[i for i in a if a%2]
print('YES' if len(od)%2==0 else 'NO') |
s360806279 | p03807 | u380653557 | 1486260585 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3316 | 188 | import sys
n = list(map(int, next(sys.stdin).split()))
if len(ns) == 1:
print('YES')
exit()
if sum(1 for n in ns if n % 2 == 1) % 2 == 0:
print('YES')
else:
print('NO')
|
s779553680 | p03807 | u380653557 | 1486260319 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 126 | import sys
if sum(for n in map(int, next(sys.stdin).split()) if n % 2 == 1) % 2 == 0:
print('YES')
else:
print('NO')
|
s376032191 | p03808 | u143509139 | 1593128930 | Python | PyPy3 (7.3.0) | py | Runtime Error | 106 | 87336 | 332 | n = int(input())
a = list(map(int, input().split()))
t = n * (n + 1) // 2
s = sum(a)
if s % t:
print('NO')
else:
c = s // t
b = [0] * n
for i in range(n):
b[i] = a[i] - a[i - 1] - c
for i in range(n):
if b[i] % n or k < 0:
print('NO')
break
else:
print('YES')
|
s486049987 | p03808 | u165374901 | 1592879789 | Python | Python (3.8.2) | py | Runtime Error | 23 | 9004 | 707 | /**
* @FileName a.cpp
* @Author kanpurin
* @Created 2020.06.22 22:36:27
**/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
ll n; cin >> n;
vector<int> a(n),b(n);
ll sum = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
if (sum % (n * (n + 1) / 2) != 0) {
puts("NO");
return 0;
}
ll k = sum / (n * (n + 1) / 2);
for (int i = 0; i < n; i++) {
b[i] = a[(i+1)%n] - a[i];
b[i] -= k;
b[i] = -b[i];
}
for (int i = 0; i < n; i++) {
if (b[i] % n != 0) {
puts("NO");
return 0;
}
}
puts("YES");
return 0;
} |
s018411837 | p03808 | u952467214 | 1588729212 | Python | PyPy3 (2.4.0) | py | Runtime Error | 217 | 58864 | 336 | import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
n = int(input())
a = list( map(int, input().split()))
sa = sum(a)
at = (n+1)*n//2
if sa%at!=0:
print('NO')
kaisu = sa//at
diff = [0]*n
for i in range(n-1):
diff = a[i]-a[i+1]
diff[n-1] = a[n]-a[1]
if sum(diff)==0:
print('YES')
else:
print('NO')
|
s873745364 | p03808 | u520276780 | 1587610660 | Python | Python (3.4.3) | py | Runtime Error | 83 | 14292 | 272 | #editorial参照
n=int(input())
a=list(map(int, input().split()))
sa= sum(a)
if sa%(n*(n+1)//2):
print("NO")
exit()
k=sa//(n*(n-1)//2)
b=[a[i]-a[i-1] -k for i in range(n)]
for i in range(n):
if b[i]%n or b[i]>0:
print("NO")
exit()
print("YES") |
s103661400 | p03808 | u149752754 | 1586436490 | Python | Python (3.4.3) | py | Runtime Error | 42 | 14252 | 306 | n = int(input())
a = list(map(int, input().split()))
if sum[a] % (n*(n+1)//2) != 0:
print('NO')
else:
times = sum[a]//(n*(n+1)//2)
jud = True
x = a[n-1]-a[0]+times
if x % n != 0:
jud = False
for i in range(1,n):
x = a[i-1]-a[i]+times
if (x < 0 | x % n != 0):
jud = False
break
print(jud) |
s555892247 | p03808 | u325227960 | 1580213758 | Python | PyPy3 (2.4.0) | py | Runtime Error | 168 | 38484 | 7 | 3
6 6 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.