November Long Challange 2020 Ada and Dishes
**Logic - **
First I sorted the array C
a= C[n-1]
Start traversing the array from last second elemet and increase time by minimum of “a and C[i]”
and update “a=abs(C[i]-a)”
for _ in range(int(input())):
n = int(input())
c = map(int, raw_input().split())
print ((n+1)/2)*c[0]
This is the correct approach bro (for 1st subtask)
and full soln
for _ in range(input()):
n = input()
c = map(int, raw_input().split(" "))
s = sum(c)
ans = s
for x in c:
ans = min(ans, max(x, s-x))
for i in range(n):
for j in range(i+1,n):
x = c[i] + c[j]
ans = min(ans, max(x, s-x))
print ans
The problem had 12222 accepted solutions. Even if there’s a remote chance that your “correct” output is giving WA it seems very unlikely. I suggest you to edit the title of the post
your logic is not correct, every case with n=2 you are returning the minimum but the answer is the maximum; when n= 3 and c=[1,2,5] the answer should be 5 and your code gives WA.
Regarding the title, as you can see, it’s a false asseveration.