Its frustrating that I got stuck in the very first problem in my first day though I am not that of a beginner.So,I saw the editorial and followed the steps.Still getting wrong answer.

So help please!!!

https://www.codechef.com/viewsolution/37809793

The code wasn’t running, so I changed few things in code for it to work:

t = int(input())

x = 0

y = 0

for i in range(t):

n = int(input())

arr = list(map(int, input().split()))

arr.sort(reverse=True)

if n < 4:

if n == 1:

print(‘first’)

elif n == 2:

x = arr[0]

y = arr[1]

if(x == y):

print(‘draw’)

else:

print(‘first’ if x > y else ‘second’)

else:

x = arr[0]

y = arr[1] + arr[2]

print(‘first’ if x > y else ‘second’)

```
else:
x = arr[0]
y = arr[1] + arr[2]
for i in range(3, n, 2):
x += arr[i]
for i in range(4, n, 2):
y += arr[i]
if(x == y):
print('draw')
else:
print('first' if x > y else 'second')
```

It is running now, but you’ll get “Wrong answer” if you try to submit this.

I would suggest this as it’s simpler and easier to understand:

for i in range (int(input())):

len_array = int(input())

a = list(map(int, input().split()))

a.sort()

a.reverse()

n1 = 0

n2 = 0

for x in range (len_array):

if x == 0 or (x % 2 == 1 and x != 1):

n1 += a[x]

else:

n2 += a[x]

```
if n1 > n2:
print("first")
elif n1 < n2:
print("second")
else:
print("draw")
```