Codeforces Round 1111 (Div. 2)

This commit is contained in:
2026-07-18 18:40:59 +02:00
parent 31bd604934
commit 531fa0bf63
3 changed files with 84 additions and 0 deletions

41
src/A. Zero Sum.py Normal file
View File

@@ -0,0 +1,41 @@
# https://codeforces.com/contest/2247/problem/A
def solve():
n = int(input())
a = list(map(int, input().split()))
S = sum(a)
if S == 0:
return print("YES")
if S % 2 != 0:
return print("NO")
if n <= abs(S):
return print("NO")
p = 0
s = 1 if S > 0 else -1
i = 0
while i < n - 1:
if a[i] == s and a[i + 1] == s:
p += 1
i += 2
else:
i += 1
if p * 2 < abs(S):
return print("NO")
return print("YES")
# solution :
# if sum(a) % 4 == 0:
# print("YES")
# else:
# print("NO")
t = int(input())
for _ in range(t):
solve()

View File

@@ -0,0 +1,16 @@
# https://codeforces.com/contest/2247/problem/B
# i gave up
import math
def solve():
n, k, m = map(int, input().split())
a = []
print(n, k, m)
t = int(input())
for _ in range(t):
solve()

View File

@@ -0,0 +1,27 @@
# https://codeforces.com/contest/2247/problem/C
# solved !!!!
def solve():
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a == b:
return print(0)
diff = [a[i] - b[i] for i in range(n)]
if all(not diff[i] or diff[i] == -1 for i in range(n)):
if 1 in a and 0 in b:
return print(2)
return print(-1)
if sum([a[i] if diff[i] else 0 for i in range(n)]) % 2 == 0:
return print(2)
else:
return print(1)
t = int(input())
for _ in range(t):
solve()