Problem:


Score: 200 points

Problem Statement

We have N cards. A number a_i is written on the i-th card.

Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.

The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

Constraints

N is an integer between 1 and 100 (inclusive).

a_i \ (1 \leq i \leq N) is an integer between 1 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:  

N
a_1 a_2 a_3 ... a_N

Output

Print Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.

Sample Input 1

2
3 1

Sample Output 1

2

First, Alice will take the card with 3. Then, Bob will take the card with 1.
The difference of their scores will be 3 - 1 = 2.

Sample Input 2

3
2 7 4

Sample Output 2

5

First, Alice will take the card with 7. Then, Bob will take the card with 4. Lastly, Alice will take the card with 2. The difference of their scores will be 7 - 4 + 2 = 5. The difference of their scores will be 3 - 1 = 2.

Sample Input 3

4
20 18 2 18

Sample Output 3

18



Sample input:
2
3 1


Sample output:
2

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
res = 0
for i in range(n):
  if i % 2 == 0:
    res += a[i]
  else:
    res -= a[i]
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
res = 0
for i in range(n):
  if n % 2 == 0:
    res += a[i]
  else:
    res -= a[i]
print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=0
a.reverse()
s=sum(a[:n:2])-sum(a[1:n:2])
print(abs(s))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=0
a.reverse()
s=sum(a[:n:2])-sum(a[1:n:2])
print(-s)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=0
a.reverse()
s=sum(a[:n:2])-sum(a[1:n:2])
print(s)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=0
a.reverse()
s=sum(a[::2])-sum(a[1::2])
print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
sum1=0
sum2=0
for num in range(N):
  if num % 2 == 0:
    sum1 += A[num]
  else:
    sum2 += A[num]
print(sum1 - sum2)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
A.sort(reverse=True)
sum1=0
sum2=0
for num in range(N+1):
  if num % 2 ==0:
    sum1 += num
  else:
    sum2 += num
print(sum1-sum2)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
A.sort()
print(A[N-1]-A[0])

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
b=sorted(a, reverse=True)
print(sum(b[0::2])-sum(b[1::2]))

Submission status: Wrong Answer

Solution code:
N = int(input())
Ai = list(map(int,input().split()))
Alice = 0
Bob = 0
Ai.append(0)

for i in Ai:
    Alice += max(Ai)
    Ai.remove(max(Ai))
    if not Ai:
        break
    Bob += max(Ai)
    Ai.remove(max(Ai))

print(Alice-Bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
Ai = list(map(int,input().split()))
Alice = 0
Bob = 0

for i in Ai:
    Alice += max(Ai)
    Ai.remove(max(Ai))
    if not Ai:
        break
    Bob += max(Ai)
    Ai.remove(max(Ai))

print(Alice-Bob)

Submission status: Wrong Answer

Solution code:


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    n = int(input())
    a = input().split()

    bob = 0
    alice = 0
    sort_a = sorted(a, reverse=True)
    count = 0
    for m in range(len(sort_a)):
        if m % 2 == 0:
            alice += int(sort_a[m])
        else:
            bob += int(sort_a[m])

    print(alice - bob)

Submission status: Wrong Answer

Solution code:


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    n = int(input())
    a = input().split()

    bob = 0
    alice = 0
    sort_a = sorted(a, reverse=True)
    count = 0
    for m in range(len(sort_a)):
        if m % 2 == 0:
            alice = alice + int(sort_a[m])
        else:
            bob = bob + int(sort_a[m])

    print(alice - bob)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
sorted_a = sorted(a)

for i in sorted_a:
    alice += sorted_a.pop()
    bob += sorted_a.pop()

print(alice - bob)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
alice = 0
bob = 0
sorted_a = sorted(a)

print(a, sorted_a)

for i in sorted_a:
    alice += sorted_a.pop()
    bob += sorted_a.pop()

print(alice - bob)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0

a.sort(reverse = True)
print(a)

for x in range(n):
   if x % 2 == 0:
      ans += a[x]
   else:
      ans -= a[x]

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0

a.sort()

for x in range(n):
   if x % 2 == 0:
      ans -= a[x]
   else:
      ans += a[x]

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = sorted(map(int, input().split()))

print(sum(a[1::2])-sum(a[::2]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [-int(x) for x in input().split()]
A.sort(reverse=True)
a, b, turn = 0, 0, 1
while len(A) != 0:
    if turn & 1:
        a += A.pop(0)
    else:
        b += A.pop(0)
    turn += 1
print(a-b)

Submission status: Wrong Answer

Solution code:
# 2020-08-30, Sun

n = int(input())
lis = sorted(list(map(int, input().split())))

print(sum(lis[1::2]) - sum(lis[::2]))

Submission status: Wrong Answer

Solution code:
# 2020-08-30, Sun

n = int(input())
lis = sorted(list(map(int, input().split())))
a = 0
b = 0

for i in lis[::2]:
    a += i

for i in lis[1::2]:
    b += i

print(b - a)

Submission status: Wrong Answer

Solution code:
# 2020-08-30, Sun

n = int(input())
lis = sorted(list(map(int, input().split())))
a = 0
b = 0

for i in lis[::2]:
    a += i

for i in lis[1::2]:
    b += i

print(a - b)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = sorted(map(int, input().split()))
a = 0
b = 0
for i in range(n):
  if i % 2 == 0:
  	a += l.pop()
  else:
    b += l.pop()
print(a)

Submission status: Wrong Answer

Solution code:
N = input()
A = list(input().split())
A = list(map(int,A))
A = sorted(A,reverse = True)
a = 0
b = 0
try :
  while len(A) != 0 :
    a += A.pop(0)
    b += A.pop(0)
except IndexError :
  print(a-b)
print(a-b)

Submission status: Wrong Answer

Solution code:
N = input()
A = list(input().split())
A = list(map(int,A))
A = sorted(A,reverse = True)
a = 0
b = 0
try :
  a += A.pop(0)
  b += A.pop(0)
except IndexError :
  print(a-b)
print(a-b)

Submission status: Wrong Answer

Solution code:
"""Boot-camp-for-Beginners_Easy010_B_Toll-Gates_29-August-2020.py"""
import numpy as np

N = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
l = len(a)
s_max = 0
s_min = 0
if l % 2 == 0:
    for i in range(int(l/2)):
        s_max += a[i]
    for i in range(int(len(a)/2), int(len(a))):
        s_min += a[i]
else:
    for i in range(int(l/2)+1):
        s_max += a[i]
    for i in range(int(len(a)/2)+1, int(len(a))):
        s_min += a[i]
# print(s_max)
# print(s_min)
print(s_max-s_min)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))

# ソートしたとき、Aliceは偶数(0,2,...)番目を、Bobは偶数(1,3,...)番目を取る
a = sorted(a, reverse=True)
A = 0
B = 0
for i in range(N):
  if A % 2 == 1: A += a[i]
  else: B += a[i]

print(A-B)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = map(int, input().split())

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    score = [0, 0]
    sort_a = sorted(a, reverse=True)
    print(sort_a)

    for i in range(n):
        if i >= 2:
            sub_i = i % 2
        else:
            sub_i = i
        score[sub_i] += sort_a[i]

    print(score[0] - score[1])


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())),reverse=True)
A = sum(a[::2])
B = sum(a[::2])
print(A - B)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
al=[a[2*i] for i in range(n//2)]
bo=[a[2*i+1] for i in range(n//2)]
print(sum(al)-sum(bo))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
al=[a[2*i] for i in range(n//2)]
bo=[a[2*i+1] for i in range(n//2)]
print(sum(al)-sum(bo))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
al=[a[2*i] for i in range(n//2)]
bo=[a[2*i+1] for i in range(n//2)]
print(sum(al)-sum(bo))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
print(sum(A[-1::2])-sum(A[-2::2]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
print(sum(A[0::2])-sum(A[1::2]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
print(a_list)

a_list.sort(reverse = True)
alice_sum = 0
bob_sum = 0
for i in range(len(a_list)):
    if i % 2 == 0:
        alice_sum += a_list[i]
    else:
        bob_sum += a_list[i]

print(alice_sum - bob_sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = sorted(list(map(int,input().split())))
print(sum(a[::2])-sum(a[1::2]))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))

print(max(a)-min(a))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
f=True
ans=0
for i in range(n):
	if(f):
		ans+=a[i]
		f=False
	else:
		f=True
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
a=list(map(int,input().split()))
a=sorted(a)
print(a)
alice=0
bob=0
if(N%2==0):
    for i in range(0,N-1,2):
        alice=a[i+1]+alice
        bob=a[i]+bob
else:
    for i in range(1,N-1,2):
        alice=a[i+1]+alice
        bob=a[i]+bob
    alice=alice+a[0]
print(alice-bob)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
Ali,Bob=0,0
for i in range(0,n-1,2):
    Ali +=a[i]
    Bob +=a[i+1]
print(Ali-Bob)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
Ali,Bob=0,0
for i in range(0,n-1,1):
    Ali +=a[i]
    Bob +=a[i+1]
print(Ali-Bob)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[int(x) for x in input().split()]
B=sorted(A)
print(B[-1])
Alice=[]
Bob=[]
while len(B)!=0 and len(B)!=1:
  Alice.append(B[-1])
  B.pop()
  Bob.append(B[-1])
  B.pop()
  print(B)
  print(len(B))
if len(B)==1:
  Alice.append(B[0])
  B.pop()
print(sum(Alice)-sum(Bob))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
alice = 0
bob = 0
A.sort(reverse=True)
print(A)
for i in range(N):
    if i%2 == 0:
        alice += A.pop(0)
    else:
        bob += A.pop(0)
print(alice-bob)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
ans=0
for i in range(n):
    ans+=a[-i]*(-1)**(i+1)
print(ans)

Submission status: Wrong Answer

Solution code:
n,*x=map(int,open(0).read().split());a=0;t=1
for i in sorted(x):a+=t*i;t*=-1
print(a)

Submission status: Wrong Answer

Solution code:
n,*t=map(int,open(0).read().split())
print(sum([i*(-1)**i for i in t]))

Submission status: Wrong Answer

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from math import ceil

n=ni()
a=nl()

sa = sorted(a)[::-1]
print(sum(a[:ceil(n/2)])-sum(a[ceil(n/2):]))

Submission status: Wrong Answer

Solution code:
n,s = int(raw_input()),map(int,raw_input().split())
s.sort(key = lambda x:-x)
print sum(s[1:n:2]) - sum(s[2:n:2])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()

a = list(map(int, a))

alice_n = a[::2]
bob_n = a[1::2]

print(sum(alice_n) - sum(bob_n))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))

alice = 0
bob = 0

for n in a:
    card = max(a)
    alice += card
    a.remove(card)
    card = max(a)
    bob += card
    a.remove(card)

print(alice - bob)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = stdin.readline().rstrip()
A = [int(x) for x in stdin.readline().rstrip().split()]

A.sort(reverse=True)

print (A)

N=M=0

for i in range(0,len(A),2):
    N = N + A[i]

for i in range(1, len(A), 2):
    M = M + A[i]

print (N-M)

Submission status: Wrong Answer

Solution code:
n = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)
# alice = []
# bob = []
res = 0
for i in range(0, n, 2):
    # alice.append(cards[i])
    # try:
    #     bob.append(cards[i+1])
    # except:
    #     break
    res += cards[i] - cards[i+1] if i + 1 < n else 0
print(res)

Submission status: Wrong Answer

Solution code:
s = input()
n = int(s)

cards = []

v = input().split()
for i in range(n):
    cards.append(v[i])

v = sorted(v,reverse=True)

alice_array = []
bob_array = []

for i in range(len(v)):
    if i % 2 == 0:
        alice_array.append(v[i])
    else:
        bob_array.append(v[i])

sum_alice = 0
sum_bob = 0
for i in range(len(alice_array)):
    sum_alice += int(alice_array[i])

for i in range(len(bob_array)):
    sum_bob += int(bob_array[i])

answer = sum_alice - sum_bob
print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = sorted(map(int, input().split()[::-1]))
print(sum(a[::2]) - sum(a[1::2]))

Submission status: Wrong Answer

Solution code:
X = int(input())
A = list(map(int, input().split()))
list.sort(A, reverse=True)
B=0
C=0
ans = 0
for i,j in enumerate(A):
    print(i)
    if (i+1)%2 != 0:
        B+=j
    else :
        C+=j
ans = B-C
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
x=0
y=0
for i in range(N):
  if i%2==0:
    x+=i
  else:
    y+=i
print(abs(x-y))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
x=0
y=0
for i in range(N):
  if i%2==0:
    x+=i
  else:
    y+=i
print(x-y)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_char = input().split(" ")


a_char.sort(reverse=True)

fugo=1
sum = 0
for i in range(0, n):
    sum += (int(a_char[i]) * fugo)
    fugo = fugo * -1

print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()

alice = sum(a[0:n:2])
bob = sum(a[1:n:2])

print(alice - bob)

Submission status: Wrong Answer

Solution code:
import math
N = int (input ())
l = input ().split ()
list.sort (l)
print (l)
a = 0
x = 0
m = math.ceil(N/2)
for i in range (m):
    x += int (l[a])
    a += 2
b = 1
y = 0
for j in range (N-m):
    y += int (l[b])
    b += 2
print (y-x)

Submission status: Wrong Answer

Solution code:
import math
N = int (input ())
l = input ().split ()
list.sort (l, reverse=True)
a = 0
x = 0
m = math.ceil(N/2)
for i in range (m):
    x += int (l[a])
    a += 2
b = 1
y = 0
for i in range (N-m):
    y += int (l[b])
    b += 2
print (x-y)

Submission status: Wrong Answer

Solution code:
import math
N = int (input ())
l = input ().split ()
list.sort (l, reverse=True)
a = 0
x = 0
m = math.ceil(N/2)
for i in range (m):
    x += int (l[a])
    a += 2
b = 1
y = 0
for i in range (N-m):
    y += int (l[b])
    b += 2
print (x-y)

Submission status: Wrong Answer

Solution code:
n = int(input())
array = list(map(int, input().split()))

bob = []
alice = []
for i in range(1, n+1):
    if i % 2 == 1:
        max_value = max(array)
        array.remove(max_value)
        alice.append(max_value)
    else:
        min_value = min(array)
        array.remove(min_value)
        bob.append(min_value)

print(sum(alice)-sum(bob))

Submission status: Wrong Answer

Solution code:
N = int(input())
an = map(int,input().split())

an_dash = sorted(an)
Bob = 0
Alice = 0


for i in an_dash:
    Bob = sum(an_dash[0::2])
for i in an_dash:
    Alice = sum(an_dash[1::2])

print(Alice - Bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
A.insert(N,0)
print(A)
ans = 0
for i in range(0,N,2):
	ans += (A[i] - A[i+1])
	print(A[i],A[i+1])
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
ans = 0
for i in range(0,N-1,2):
	ans += (A[i] - A[i+1])
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
ans = 0
for i in range(N-1):
	ans += (A[i] - A[i+1])
print(ans)

Submission status: Wrong Answer

Solution code:
n=input()
l=list(map(int,input().split()))
print(max(l)-min(l))

Submission status: Wrong Answer

Solution code:
n = int(input())
al = list(map(int, input().split()))

alice = sum(al[::2])
bob =  sum(al[1::2])

print(alice-bob)

Submission status: Wrong Answer

Solution code:
N =int(input())
a = list(map(int, input().split()))
b = sorted(a,reverse=True)
Alice = sum(b[::2])
Bob = sum(b[1::2])
ans = Alice - Bob
print(ans)
print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
for i in range(n):
    if a[i] % 2 == 0:
        ans += a[i]
    else:
        ans -= a[i]

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(map(int,input().split()))
s=sorted(s)
 
#Alice,Bob
a=[]
b=[]
 
for i in range(n):
    if i%2==0:
        a.append(s[i])
    else:
        b.append(s[i])
        
print(sum(a)-sum(b))

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
A = LI()

A.sort()
A = A[::-1]
alice = 0
bob = 0
flag = 0
for i in A:

    if flag % 2 == 0:
        alice += i
    else:
        bob += i
    flag += 1
print(alice, bob)

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
A = LI()

A.sort()
alice = 0
bob = 0
flag = 0
for i in A:
    if flag % 2 == 0:
        alice += i
    else:
        bob += i
    flag += 1
print(alice-bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
Alice=0
Bob=0
for i in range(N):
    if i % 2 ==0:
        Alice+=a[i]
    else:
        Bob+=a[i]
if Alice>Bob:
    print(Alice-Bob)
else:
    print(Bob-Alice)

Submission status: Wrong Answer

Solution code:

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

alice_point = 0
bob_point = 0

def pick_card(card_list):
    # print(card_list)
    max = 0
    max_index = 0
    for i in range(card_list.__len__()):
        # print('-------', i)
        if card_list[i] > max:
            # print('@', i, ':', max, '<', card_list[i])
            max = card_list[i]
            max_index = i
    
    del card_list[max_index]

    # print('----', card_list)

    return max, card_list

def sort_card(card_list: list):
    return sorted(card_list, reverse=True)

turn = 0
sorted_list = sort_card(card_list)
while turn < n:
    # print('--', turn)
    if turn % 2 == 0:
        # alice_get, remain_list = pick_card(card_list)
        # alice_point += alice_get
        alice_point += sorted_list.pop(0)
    else:
        # bob_get, remain_list = pick_card(card_list)
        # bob_point += bob_get
        bob_point += sorted_list.pop(0)

    # card_list = remain_list
    print(alice_point, bob_point, card_list)

    turn += 1

print(alice_point - bob_point)

Submission status: Wrong Answer

Solution code:

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

alice_point = 0
bob_point = 0

def pick_card(card_list):
    # print(card_list)
    max = 0
    max_index = 0
    for i in range(card_list.__len__()):
        # print('-------', i)
        if card_list[i] > max:
            # print('@', i, ':', max, '<', card_list[i])
            max = card_list[i]
            max_index = i
    
    del card_list[max_index]

    # print('----', card_list)

    return max, card_list

def sort_card(card_list: list):
    return sorted(card_list)

turn = 0
while turn < n:
    # print('--', turn)
    sorted_list = sort_card(card_list)
    if turn % 2 == 0:
        # alice_get, remain_list = pick_card(card_list)
        # alice_point += alice_get
        alice_point += sorted_list.pop()
    else:
        # bob_get, remain_list = pick_card(card_list)
        # bob_point += bob_get
        bob_point += sorted_list.pop()

    # card_list = remain_list
    # print(alice_point, bob_point, card_list)

    turn += 1

print(alice_point - bob_point)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
print(sum(A[::2]) - sum(A[1::2]))

Submission status: Wrong Answer

Solution code:
import sys
import itertools
input = sys.stdin.readline

N = int(input())
a = sorted([int(i) for i in input().split()])

bob_filter = [i % 2 for i in range(len(a))]
alice_filter = [not i for i in bob_filter]
result = sum(list(itertools.compress(a, bob_filter))) \
         - sum(list(itertools.compress(a, alice_filter)))

print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
A =[i for i in map(int,input().split())]
A = sorted(A,reverse=True)
print(A)
Alice = 0
Bob = 0
while len(A) != 0:
    Alice += int(A.pop(0))
    if len(A) == 0:
        break
    else:
        Bob += int(A.pop(0))

print(Alice - Bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
A =[i for i in input().split()]
A = sorted(A,reverse=True)
Alice = 0
Bob = 0
while len(A) != 0:
    Alice += int(A.pop(0))
    if len(A) == 0:
        break
    else:
        Bob += int(A.pop(0))
print(Alice - Bob)

Submission status: Wrong Answer

Solution code:
N=int(input())
an=map(int,input().split())
Cards=[]
for a in an:
    Cards.append(int(a))
Cards.sort
AliceCards=Cards[0::2]
BobsCards=Cards[1::2]
print(sum(AliceCards)-sum(BobsCards))

Submission status: Wrong Answer

Solution code:
def main():
    target_num = input()
    target_list = input().split()

    target_list.sort(reverse=True)

    result_a = 0
    result_b = 0
    a_flg = True
    for target in target_list:
        if a_flg:
            result_a += int(target)
            a_flg = False
        else:
            result_b += int(target)
            a_flg = True

    print(result_a - result_b)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
print(sum(a[0::2])  - sum(a[1::2]))

Submission status: Wrong Answer

Solution code:
input()
a = list(map(int, input().split()))
print(max(a) - min(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
lista = list(map(int, input().split()))

listb=sorted(lista, reverse=True)
print(listb)


alice=0
bob=0
for i in range(n):
        if i % 2 ==0:
            alice += listb[i]
        else:
            bob += listb[i]


print(alice-bob)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_sort = sorted(a, reverse=True)
    alice = 0
    bob = 0
    for i in range(n):
        print(i)
        if i % 2 == 0:
            alice += a_sort[i]
        else:
            bob += a_sort[i]
    res = alice - bob
    print(res)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
sumA = 0
sumB = 0

for i in range(len(a)):
    if i % 2 == 0:
        sumA += a[i]
    else:
        sumB += a[i]

Submission status: Wrong Answer

Solution code:
_, *a = map(int, open(0).read().split())
a.sort()
print(sum(a[-1::2]) - sum(a[-2::2]))

Submission status: Wrong Answer

Solution code:
N = int(input())
card = list(map(int,input().split()))

card.reverse()

alice = 0
bob = 0
for i in range(len(card)):
    if i % 2 == 0:
        alice += card[i]
    else:
        bob += card[i]

print(alice - bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
card = list(map(int,input().split()))

card.sort()

alice = 0
bob = 0
for i in range(len(card)):
    if i % 2 == 0:
        alice += card[i]
    else:
        bob += card[i]

print(alice - bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
card = list(map(int,input().split()))
sorted_card = sorted(card)
Alice = 0
Bob = 0

for i in range(N):
    if i == 0 or i % 2 == 0:
        Alice += sorted_card[i]
    else:
        Bob += sorted_card[i]

print(Alice - Bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
card = list(map(int,input().split()))
sorted_card = sorted(card)
Alice = 0
Bob = 0

for i in range(N):
    if i % 2 == 0:
        Alice += sorted_card[i]
    else:
        Bob += sorted_card[i]

print(Alice - Bob)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
alice=0
bob=0
for i in range(n):
    if n%2==0:
        alice+=a[i]
    else:
        bob+=a[i]
print(alice-bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)

Alice = 0
Bob = 0

print(a_list)

for i in range(len(a_list)):
    if i % 2 == 0:
        Alice += a_list[i]
    else:
        Bob += a_list[i]

print(Alice-Bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = map(int, input().split())

a = sorted(a, reverse=True)

Alice = 0
Bob = 0

if N == 3:
    print((a[2] + a[0]) - a[1])

else:
    for i in range(0,N-1,2):
        Alice += a[i]
        Bob += a[i+1]
    
    print(Alice-Bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = map(int, input().split())

a = sorted(a, reverse=True)

Alice = 0
Bob = 0

for i in range(0,N-2,2):
    Alice += a[i]
    Bob += a[i+1]


print(Alice-Bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = map(int, input().split())

a = sorted(a, reverse=True)

Alice = 0
Bob = 0

for i in range(0,N-1,2):
    Alice += a[i]
    Bob += a[i+1]


print(Alice-Bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = map(int, input().split())

a = sorted(a, reverse=True)

Alice = 0
Bob = 0

for i in range(N-1):
    Alice += a[i]
    Bob += a[i+1]


print(Alice-Bob)

Submission status: Wrong Answer

Solution code:
import math
from collections import deque
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

n = readInt()
a = readInts()
a.sort()
if len(a)%2:
	a.append(0)
alice = 0
bob = 0
for i in range(0,len(a),2):
	alice+=a[i]
	bob+=a[i+1]
print(alice-bob)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n = int(input())
    k = [int(i) for i in input().split()]
    a = 0
    b = 0
    k.sort(reverse=True)
    print(k)
    flag = True
    for i in k:
        if flag == True:
            a+=i
            flag=False
        else:
            b+=i
            flag=True
    print(a-b)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(map(int,input().split()))
print(sum(a[1::2])-sum(a[::2]))