From e2b512e02a27a0fe924c9bb70eccc49d9ee91ec2 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Sat, 11 Jan 2025 14:24:59 +0000 Subject: [PATCH] solutions: 160A --- solutions/twins.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 solutions/twins.py diff --git a/solutions/twins.py b/solutions/twins.py new file mode 100644 index 0000000..cde8c70 --- /dev/null +++ b/solutions/twins.py @@ -0,0 +1,25 @@ +n = int(input()) +a = [int(c) for c in input().split(' ')] + +vals = [] + +def find(a): + count = 0 + first = 0 + second = sum(a) + + for i in a: + first += i + second -= i + + count += 1 + + if first > second: + vals.append(count) + break + if len(vals) >= 2: + return + find(a[::-1]) +find(sorted(a)) + +print(min(vals))