PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author:
Tester: apoorv_me
Editorialist: iceknight1093
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
Ved’s height is K, and Varun’s height is P.
There are N chairs, the i-th has height A_i.
Varun will take all the chairs except the one with maximum height, while Ved will take the one with maximum height.
Each person will stack up all the chairs they have and then stand on top of the stack.
Who will have a better view, i.e., be taller in the end?
EXPLANATION:
Ved will take the chair with maximum height, which is \max(A).
So, his overall height will be K + \max(A).
Varun will take all chairs other than this one chair, and stack them up, attaining a height increase of \text{sum}(A) - \max(A).
So, his overall height will be V + \text{sum}(A) - \max(A).
Compare the final heights and print the answer appropriately.
TIME COMPLEXITY:
\mathcal{O}(N) per testcase.
CODE:
Editorialist's code (PyPy3)
for _ in range(int(input())):
n, k, p = map(int, input().split())
a = list(map(int, input().split()))
k += max(a)
p += sum(a) - max(a)
if k > p: print('Ved')
elif k == p: print('Equal')
else: print('Varun')