AtCoder Beginner Contest 117 - Polygon

Determine if an N-sided polygon (not necessarily convex) with sides of length L_1, L_2, ..., L_N can be drawn in a two-dimensional plane.
You can use the following theorem:
Theorem: an N-sided polygon satisfying the condition can be drawn if and only if the longest side is strictly shorter than the sum of the lengths of the other N-1 sides.

-----Constraints-----
 - All values in input are integers.
 - 3 \leq N \leq 10
 - 1 \leq L_i \leq 100

-----Input-----
Input is given from Standard Input in the following format:
N
L_1 L_2 ... L_N

-----Output-----
If an N-sided polygon satisfying the condition can be drawn, print Yes; otherwise, print No.

-----Sample Input-----
4
3 8 5 1

-----Sample Output-----
Yes

Since 8 < 9 = 3 + 5 + 1, it follows from the theorem that such a polygon can be drawn on a plane.

Source: atcoder | Difficulty: EASY


Solutions:
N = int(input())
A = list(map(int, input().split()))
print('Yes' if max(A) < sum(A) - max(A) else 'No')


_ = input()
L = sorted(map(int, input().split()))
print('Yes' if L[-1] * 2 < sum(L) else 'No')


N = int(input())
L = list(map(int, input().split()))
print('YNeos'[max(L) * 2 >= sum(L)::2])


n = int(input())
l = list(map(int, input().split()))
l.sort()
if sum(l[0:n - 1]) > l[n - 1]:
	print('Yes')
else:
	print('No')


N = int(input())
L = sorted(map(int, input().split()))
print('Yes' if sum(L[:-1]) > L[-1] else 'No')


n = int(input())
l = sorted(map(int, input().split()))
print(['No', 'Yes'][l[-1] < sum(l) - l[-1]])


N = int(input())
data = list(map(int, input().split()))
max = 0
kei = 0
for i in range(len(data)):
	kei += data[i]
	if max < data[i]:
		max = data[i]
if max < kei - max:
	print('Yes')
else:
	print('No')


n = int(input())
l = list(map(int, input().split()))
print('No' if sum(l) - max(l) <= max(l) else 'Yes')


N = int(input())
L = list(map(int, input().split()))
L.sort()
print('Yes' if L[-1] < sum(L[:-1]) else 'No')


N = int(input())
L = list(map(int, input().split()))
if max(L) < sum(L) - max(L):
	answer = 'Yes'
else:
	answer = 'No'
print(answer)


n = input()
(*l, a) = sorted(map(int, input().split()))
if sum(l) > a:
	print('Yes')
else:
	print('No')


_ = int(input())
L = sorted(list(map(int, input().split())))
print('NYoe s'[max(L) < sum(L) - max(L)::2])


input()
L = list(map(int, input().split()))
print('No') if max(L) * 2 >= sum(L) else print('Yes')


n = int(input())
l = list(map(int, input().split()))
sum = 0
for i in range(n):
	sum += l[i]
print('Yes' if max(l) * 2 < sum else 'No')


input()
l = [int(i) for i in input().split()]
print(['Yes', 'No'][max(l) - (sum(l) - max(l)) >= 0])


polygon_side = int(input())
side_length = list(map(int, input().split()))
if max(side_length) * 2 < sum(side_length):
	print('Yes')
else:
	print('No')


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	n = int(input())
	l = sorted(Input())
	(x, y) = (sum(l[:-1]), l[-1])
	print('Yes' if y < x else 'No')
main()


N = int(input())
S = map(int, input().split())
length_list = list(S)
length_list.sort(reverse=True)
max_length = length_list.pop(0)
if max_length < sum(length_list):
	print('Yes')
else:
	print('No')


n = int(input())
a = list(map(int, input().split()))
m = 0
t = 0
for i in range(n):
	m += a[i]
for i in range(n):
	t += 2 * a[i] >= m
if t == 0:
	print('Yes')
else:
	print('No')


S_list = [input() for i in range(2)]
N = map(int, S_list[0].split())
L_list = list(map(int, S_list[1].split()))
if sum(L_list) > max(L_list) * 2:
	result = 'Yes'
else:
	result = 'No'
print(result)


n = int(input())
l = list(map(int, input().split()))
m = max(l)
l.pop(l.index(m))
if m < sum(l):
	print('Yes')
else:
	print('No')


n = int(input())
l = sorted(map(int, input().split()))
print('Yes' if 2 * l[-1] < sum(l) else 'No')


N = int(input())
a = list(map(int, input().split()))
print('Yes' if max(a) * 2 < sum(a) else 'No')


N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N):
	ans += L[i]
if max(L) < sum(L) - max(L):
	print('Yes')
else:
	print('No')


input()
l = list(map(int, input().split()))
l.sort()
m = l.pop()
print('Yes' * (m < sum(l)) or 'No')


N = int(input())
L = [int(i) for i in input().split()]
print('Yes' if 2 * max(L) < sum(L) else 'No')


def atc_117b(N: int, Li_input: str) -> str:
	Li = [int(i) for i in Li_input.split(' ')]
	Li = sorted(Li)
	max_length = Li.pop()
	if max_length < sum(Li):
		return 'Yes'
	return 'No'
N_input_value = int(input())
Li_input_value = input()
print(atc_117b(N_input_value, Li_input_value))


n = int(input())
l = list(map(int, input().split()))
print('YNeos'[sum(l) <= max(l) * 2::2])


polynum = int(input())
length = list(map(int, input().split()))
most_l = max(length)
othersum = sum(length) - most_l
if othersum > most_l:
	print('Yes')
else:
	print('No')


n = int(input())
p = sorted(map(int, input().split()))[::-1]
print('Yes' if p[0] < sum(p[1:]) else 'No')


N = int(input())
L = list(map(int, input().split()))
a = max(L)
L.remove(a)
s = 0
for i in L:
	s += i
if a < s:
	print('Yes')
else:
	print('No')


input()
(*a,) = map(int, input().split())
print('YNeos'[sum(a) <= max(a) * 2::2])


input()
lst = list(map(int, input().split()))
print('Yes' if max(lst) < sum(lst) - max(lst) else 'No')


input()
n = [int(x) for x in input().split()]
print('Yes' if sum(n) - max(n) > max(n) else 'No')


print((lambda n, a: 'Yes' if max(a) * 2 < sum(a) else 'No')(input(), list(map(int, input().split()))))


n = input()
l = sorted(map(int, input().split()))
print('YNeos'[sum(l[:-1]) <= l[-1]::2])


N = int(input())
L = list(map(int, input().split()))
a = max(L)
b = sum(L) - a
print('Yes' if b > a else 'No')


n = int(input())
p = list(map(int, input().split()))
print('Yes' if 2 * max(p) < sum(p) else 'No')


input()
l = [int(x) for x in input().split()]
l.sort()
print('Yes' if sum(l[:-1]) > l[-1] else 'No')


(N, L) = open(0)
L = sorted(map(int, L.split()))
print('YNeos'[sum(L[:-1]) <= L[-1]::2])


N = int(input())
LN = [int(x) for x in input().split()]
print('YNeos'[max(LN) >= sum(LN) - max(LN)::2])


(_, *s) = map(int, open(0).read().split())
print('YNeos'[sum(s) - max(s) * 2 < 1::2])


(n, *a) = map(int, open(0).read().split())
a.sort()
print('YNeos'[sum(a[:-1]) <= a[-1]::2])


N = int(input())
L = list(map(int, input().split()))
ans = True
for i in range(N):
	sum = 0
	for j in range(N):
		if i == j:
			continue
		else:
			sum += L[j]
	if L[i] >= sum:
		ans = False
if ans == True:
	print('Yes')
else:
	print('No')


n = input()
l = list(map(int, input().split()))
l.sort()
x = l.pop(-1)
print('Yes' if sum(l) > x else 'No')


input()
l = sorted(map(int, input().split()))
m = l.pop()
t = sum(l)
print('Yes' if m < t else 'No')


N = input()
L = list(map(int, input().split()))
L.sort(reverse=True)
print(['No', 'Yes'][L[0] < sum(L[1:])])


(n, *l) = map(int, open(0).read().split())
l.sort(reverse=True)
print('Yes' if l[0] < sum(l[1:]) else 'No')


n = int(input())
h = sorted(list(map(int, input().split())))
print('Yes' if sum(h) > 2 * h[-1] else 'No')


N = int(input())
l = list(map(int, input().split()))
sum = 0
flg = True
for i in range(N):
	sum = sum + l[i]
for j in range(N):
	if sum - l[j] <= l[j]:
		flg = False
		break
if flg == True:
	print('Yes')
else:
	print('No')


N = int(input())
L = list(map(int, input().split()))
L.sort()
length = 0
for i in range(N - 1):
	length += L[i]
if length > L[N - 1]:
	print('Yes')
else:
	print('No')


import sys
input = sys.stdin.readline

def main():
	N = int(input())
	L = list(map(int, input().split()))
	if max(L) < sum(L) - max(L):
		print('Yes')
	else:
		print('No')

def __starting_point():
	main()
__starting_point()


a = input()
b = [int(i) for i in input().split()]
print(['No', 'Yes'][sum(b) > 2 * max(b)])


u = input()
length = list(input().split())
h = [int(i) for i in length]
if max(h) < sum(h) - max(h):
	print('Yes')
else:
	print('No')


_ = int(input())
L = list(map(int, input().split()))
print('YNeos'[max(L) >= sum(L) - max(L)::2])


a = [input().split() for l in range(2)]
N = int(a[0][0])
L = a[1]
sum = 0
for i in range(N):
	sum += int(L[i])
l_tf = []
for i in range(N):
	if 2 * int(L[i]) >= sum:
		print('No')
		break
else:
	print('Yes')


input()
l = [int(x) for x in input().split()]
print(['No', 'Yes'][2 * max(l) < sum(l)])


N = int(input())
l = [int(i) for i in input().split()]
print('Yes' if max(l) < sum(l) - max(l) else 'No')


N = int(input())
L = list(map(int, input().split()))
mx = L.pop(L.index(max(L)))
if mx < sum(L):
	print('Yes')
else:
	print('No')
pass


input()
(a, *b) = sorted(map(int, input().split()), reverse=True)
print('Yes' if a < sum(b) else 'No')


n = int(input())
al = list(map(int, input().split()))
al_max = max(al)
al_sum = sum(al)
if al_sum - al_max * 2 > 0:
	print('Yes')
else:
	print('No')


(n, *a) = map(int, open(0).read().split())
print('YNeos'[sum(a) <= max(a) * 2::2])


out = ['No', 'Yes']
n = int(input())
li = list(map(int, input().split()))
print(out[max(li) * 2 < sum(li)])


input()
l = [int(i) for i in input().split()]
print('Yes' if sum(l) - 2 * max(l) > 0 else 'No')


def main():
	input()
	l = list(map(int, input().split()))
	m = max(l)
	s = sum(l) - m
	ans = 'Yes' if m < s else 'No'
	print(ans)

def __starting_point():
	main()
__starting_point()


N = int(input())
len = list(map(int, input().split()))
short_len = sum(len) - max(len)
result = 'Yes' if short_len > max(len) else 'No'
print(result)


N = int(input())
N_List = list(map(int, input().split()))
maxN = max(N_List)
print(('No', 'Yes')[sum(N_List) - maxN > maxN])


N = int(input())
l = list(map(int, input().split()))
max_l = max(l)
sum_l = sum(l) - max_l
if sum_l - max_l > 0:
	print('Yes')
else:
	print('No')


n = int(input())
l = sorted([int(i) for i in input().split()])
print('Yes' if l[-1] < sum(l[:-1]) else 'No')


N = int(input())
L = list(map(int, input().split()))
m = max(L)
L.pop(L.index(max(L)))
if m < sum(L):
	print('Yes')
else:
	print('No')


_ = input()
L = sorted(list(map(int, input().split())))
print('YNeos'[sum(L[:-1]) <= L[-1]::2])


N = int(input())
my_list = list(map(int, input().split(maxsplit=N)))
sorted_list = sorted(my_list, reverse=True)
num = 0
for i in range(1, len(my_list)):
	num += sorted_list[i]
if sorted_list[0] < num:
	answer = 'Yes'
else:
	answer = 'No'
print(answer)


def lcm(a, b):
	return a * b // math.gcd(a, b)
MOD = 10 ** 9 + 7
n = int(input())
L = list(map(int, input().split()))
m = max(L)
L.remove(m)
s = sum(L)
if m < s:
	print('Yes')
else:
	print('No')


input()
l = sorted(list(map(int, input().split())))
print('Yes' if l[-1] < sum(l[0:-1]) else 'No')


input()
a = list(map(int, input().split()))
print(['No', 'Yes'][max(a) < sum(a) - max(a)])


i = input
i()
l = list(map(int, i().split()))
print(['No', 'Yes'][max(l) * 2 < sum(l)])


n = int(input())
l = [int(_) for _ in input().split()]
print('Yes' if max(l) < sum(l) - max(l) else 'No')


input()
L = list(map(int, input().split()))
m = max(L)
L.remove(m)
print('Yes' if sum(L) > m else 'No')


input()
li = sorted(map(int, input().split()))
print('Yes' if li[-1] < sum(li) - li[-1] else 'No')


N = int(input())
(*A,) = map(int, input().split())
print('YNeos'[sum(A) <= max(A) * 2::2])


N = int(input())
L = tuple(map(int, input().split()))
print('Yes' if sum(L) - max(L) > max(L) else 'No')


input()
l = list(map(int, input().split()))
m = max(l)
print('Yes' if m * 2 < sum(l) else 'No')


n = input()
a = [int(i) for i in input().split()]
print('Yes' if sum(a) > max(a) * 2 else 'No')


N = int(input())
data = list(map(int, input().split()))
data_2 = max(data) < sum(data) - max(data)
if data_2:
	print('Yes')
else:
	print('No')


(_, a) = open(0)
(*a,) = map(int, a.split())
print('YNeos'[sum(a) <= max(a) * 2::2])


N = int(input())
L = list(map(int, input().split()))
M = max(L)
m = L.index(M)
s = sum(L[:m]) + sum(L[m + 1:])
if M < s:
	print('Yes')
else:
	print('No')


(_, a) = (input(), sorted(list(map(int, input().split()))))
print('Yes' if sum(a[0:-1]) > a[-1] else 'No')


N = input()
num = list(map(int, input().split(' ')))
max_num = max(num)
num.remove(max_num)
num_sum = 0
for i in num:
	num_sum += i
if max_num < num_sum:
	print('Yes')
else:
	print('No')


N = int(input())
a = list(map(int, input().split()))
edge_list = list(a)
edge_list.sort(reverse=True)
longest_edge = edge_list.pop(0)
left_sum = 0
for i in edge_list:
	left_sum += i
if longest_edge < left_sum:
	print('Yes')
else:
	print('No')


N = list(map(int, input().split()))
side = list(map(int, input().split()))
long_side = max(side)
total = 0
for i in side:
	total += i
total -= long_side
if long_side < total:
	print('Yes')
else:
	print('No')


n = int(input())
m = sorted(map(int, input().split()))
print('Yes' if m[-1] < sum(m[:-1]) else 'No')


(n, *l) = map(int, open(0).read().split())
print('YNeos'[max(l) >= sum(sorted(l)[:-1])::2])


(_, *l) = map(int, open(0).read().split())
l.sort()
print('YNeos'[sum(l[:-1]) <= l[-1]::2])


def generate_polygon(length: list) -> str:
	length.sort()
	len_max = length.pop()
	len_sum = sum(length)
	if len_max < len_sum:
		return 'Yes'
	return 'No'

def __starting_point():
	n = int(input())
	length = list(map(int, input().split()))
	print(generate_polygon(length))
__starting_point()


N = int(input())
L = list(map(int, input().split()))
print(['Yes', 'No'][max(L) >= sum(L) - max(L)])


num = int(input())
edges = list(map(int, input().split(' ')))
can_draw = 0
edges.sort(reverse=True)
if edges[0] < sum(edges[1:]):
	print('Yes')
else:
	print('No')


n = int(input())
li = list(map(int, input().split()))
li.sort()
su = sum(li)
if li[n - 1] < su - li[n - 1]:
	print('Yes')
else:
	print('No')


n = int(input())
l = sorted(list(map(int, input().split())))
m = l.pop(-1)
print('Yes' if m < sum(l) else 'No')


n = int(input())
l_list = [int(i) for i in input().split()]
if max(l_list) < sum(l_list) - max(l_list):
	print('Yes')
else:
	print('No')


_n = input()
lines = list(map(int, input().split()))
lines.sort()
longest = lines.pop()
if sum(lines) > longest:
	print('Yes')
else:
	print('No')


n = int(input())
l = list(map(int, input().split()))
l.sort()
mx = l.pop()
print('Yes' if sum(l) > mx else 'No')


n = int(input())
l = list(map(int, input().split()))
print(('No', 'Yes')[sum(l) - max(l) - max(l) > 0])


input()
(*a, b) = sorted(map(int, input().split()))
print('YNeos'[sum(a) <= b::2])


n = input()
L = sorted(list(map(int, input().split())))
if sum(L[:-1]) > L[-1]:
	print('Yes')
else:
	print('No')


(N, *L) = map(int, open(0).read().split())
print('NYoe s'[2 * max(L) < sum(L)::2])


n = int(input())
l = list(map(int, input().split()))
l.sort()
sum = 0
for i in range(n - 1):
	sum += l[i]
if l[-1] < sum:
	print('Yes')
else:
	print('No')


input()
(*s,) = map(int, input().split())
print('YNeos'[sum(s) - max(s) * 2 < 1::2])


N = int(input())
L = sorted(list(map(int, input().split())))
m = L[-1]
s = sum(L[:-1])
if m < s:
	print('Yes')
else:
	print('No')


N = int(input())
L = list(map(int, input().split()))
long = max(L)
other = sum(L) - long
if long < other:
	print('Yes')
else:
	print('No')


N = int(input())
L = list(map(int, input().split()))
m = max(L)
s = sum(L) - m
if m < s:
	print('Yes')
else:
	print('No')


input()
v = sorted(map(int, input().split()))
print('YNeos'[v[-1] >= sum(v[:-1])::2])


N = int(input())
L = list(map(int, input().split()))
descending_L = sorted(L, reverse=True)
other_side = sum(descending_L[1:])
if descending_L[0] < other_side:
	print('Yes')
else:
	print('No')


n = int(input())
l = list(map(int, input().split()))

def answer(n: int, l: list) -> str:
	if max(l) < sum(l) - max(l):
		return 'Yes'
	else:
		return 'No'
print(answer(n, l))


n = int(input())
list01 = input().split()
list02 = sorted([int(s) for s in list01])
a = sum(list02) - list02[-1]
if list02[-1] < a:
	print('Yes')
else:
	print('No')


N = int(input())
L = list(map(int, input().split()))
x = sum(L)
for l in L:
	if l >= x - l:
		print('No')
		break
else:
	print('Yes')


N = int(input())
widths = list(map(int, input().split()))
Notmax_widths = sum(widths) - max(widths)
result = 'Yes' if Notmax_widths > max(widths) else 'No'
print(result)


(n, *l) = map(int, open(0).read().split())
l.sort()
print(['No', 'Yes'][l[-1] < sum(l[:-1])])


n = int(input())
li = list(map(int, input().split()))
li.sort()
sum = 0
for a in li:
	sum += a
if sum - li[len(li) - 1] > li[len(li) - 1]:
	print('Yes')
else:
	print('No')


input()
(l, *L) = sorted(map(int, input().split()), reverse=True)
print('Yes' if sum(L) > l else 'No')


input()
l = list(map(int, input().split()))
print(['No', 'Yes'][max(l) < sum(l) - max(l)])


n = int(input())
long = list(map(int, input().split()))
one = max(long)
ans = sum(long) - one
if ans > one:
	print('Yes')
else:
	print('No')


_ = input()
n = [int(i) for i in input().split()]
print('YNeos'[0 >= sum(n) - max(n) * 2::2])


n = int(input())
l = list(map(int, input().split()))
all_l = sum(l)
max_l = max(l)
com = all_l - max_l
if com > max_l:
	print('Yes')
else:
	print('No')


_ = input()
(*l, m) = sorted(map(int, input().split()))
print('Yes' if sum(l) > m else 'No')