diff --git a/src/A. Zero Sum.py b/src/A. Zero Sum.py new file mode 100644 index 0000000..d2e1fab --- /dev/null +++ b/src/A. Zero Sum.py @@ -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() \ No newline at end of file diff --git a/src/B. Yet Another Constructive.py b/src/B. Yet Another Constructive.py new file mode 100644 index 0000000..eae993a --- /dev/null +++ b/src/B. Yet Another Constructive.py @@ -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() \ No newline at end of file diff --git a/src/C. Inversion of a Subsequence.py b/src/C. Inversion of a Subsequence.py new file mode 100644 index 0000000..191385b --- /dev/null +++ b/src/C. Inversion of a Subsequence.py @@ -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() \ No newline at end of file