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:
data = [input() for x in range(0, 2, 1)]

cards = [int(x) for x in data[1].split(" ")]

#バブルソート
for i in range(0, len(cards), 1):
  
  for j in range(i + 1, len(cards), 1):
    
    if cards[i] > cards[j]:
      tmp1 = cards[i]
      tmp2 = cards[j]
      
      cards[i] = tmp2
      cards[j] = tmp1
      
alice = 0
bob = 0

#cardsをソート

for i, v in enumerate(cards):
  
  if i %2 == 0:
    alice += v
  else:
    bob += v
    
print(alice - bob)

Submission status: Wrong Answer

Solution code:
data = [input() for x in range(0, 2, 1)]

cards = [int(x) for x in data[1].split(" ")]

#バブルソート
for i in range(0, len(cards), 1):
  
  for j in range(i + 1, len(cards), 1):
    
    if cards[i] > cards[j]:
      tmp1 = cards[i]
      tmp2 = cards[j]
      
      cards[i] = tmp2
      cards[j] = tmp1
      
print(cards)

alice = 0
bob = 0

#cardsをソート

for i, v in enumerate(cards):
  
  if i %2 == 0:
    alice += v
  else:
    bob += v
    
print(alice - bob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 整数の入力
n = input()
n = int(n)

# いくつあるかわからないときのスペース区切りの整数の入力
nums = input().split()
nums = list(map(int,nums))

print(nums)

nums.sort(reverse=True)

print(nums)

i = 0
Alis = 0
Bob = 0

for i in range(0,n):
    if i % 2 == 0:
        Alis = Alis + nums[i]
    else:
        Bob = Bob + nums[i]

print(Alis-Bob)

#print(Alis)
#print(Bob)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(map(int,input().split()))
s.sort()
a=[int(i) for i in s[::-2]]
b=[int(j) for j in s[1::-2]]
print(sum(a)-sum(b))

Submission status: Wrong Answer

Solution code:
# ABC088B - Card Game for Two
import sys

input = sys.stdin.readline

n = int(input())
lst = sorted(list(map(int, input().rstrip().split())), reverse=True)

print(sum(i for i in lst if i % 2 == 0) - sum(i for i in lst if i % 2 == 1))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list()
for x in input().split():
    a.append(x)
s=0
t=0

if n%2==0:
    c=0
    while c<n/2:
        x=max(a)
        s=s+int(x)
        a.remove(x)
        y=max(a)
        t=t+int(y)
        a.remove(y)
        c=c+1
else:
    c=0
    l=(n-1)/2
    while c<l:
        x=max(a)
        s=s+int(x)
        a.remove(x)
        y=max(a)
        t=t+int(y)
        a.remove(y)
        c=c+1
    s=s+int(a[0])
print(s-t)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

Submission status: Wrong Answer

Solution code:
N = int(input())
aList = list(map(int, input().split()))
aList.sort(reverse = True)
point = [0, 0]
for i in range(N):
    point[i%2] = aList[i]
print(point[0] - point[1])

Submission status: Wrong Answer

Solution code:
N = int(input())
list_an = input().split()
list_an_int = [int(s) for s in list_an]

list_an_int.sort()
list_an_int.reverse()

print(list_an_int)
Alice_counter = 0
Bob_counter = 0

counter = 0
for i in range(N):
    if counter % 2 == 0:
        Alice_counter += list_an_int[i]
    else:
        Bob_counter += list_an_int[i]
    counter += 1
print(Alice_counter - Bob_counter)

Submission status: Wrong Answer

Solution code:
n=int(raw_input())

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

a.sort()
a.reverse()
print a
ali=0
bob=0

while len(a)>0:
	ali+=a[0]
	del a[0]
	if len(a)==0:
		break
	else:
		bob+=a[0]
		del a[0]

print ali-bob

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = input()
li = input().split()
li.sort(reverse=True)
t = 0
ans = 0
for i in li:
  if t % 2 == 0:
    ans += int(i)
  else:
    ans -= int(i)
  t += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
cards = sorted(map(int, input().split()), reverse=True)
score_alice, score_bob = 0, 0

for i in range(n):
  if i % 2 == 1:
    score_alice += cards[i]
  else:
    score_bob += cards[i]

print(score_alice - score_bob)

Submission status: Wrong Answer

Solution code:
n=int(input())
li=list(map(int,input().split()))
li.sort
a=[]
b=[]
for i in range(n):
  if n%2==1:
    if i%2==0:
      a.append(li[i])
    else:
      b.append(li[i])
  else:
    if i%2==0:
      b.append(li[i])
    else:
      a.append(li[i])
print(sum(a)-sum(b))

Submission status: Wrong Answer

Solution code:
n = int(input())
cards = input().split()
sorted_cards = sorted(cards)

alice = []
bob = []

for i in range(1, n+1):
    if i % 2 == 1:
        m = max(sorted_cards)
        alice.append(m)
        sorted_cards.remove(m)
    else:
        m = max(sorted_cards)
        bob.append(m)
        sorted_cards.remove(m)

a_sum, b_sum = 0, 0
for a in alice:
    a_sum += int(a)

for b in bob:
    b_sum += int(b)

print(a_sum - b_sum)

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(0,n,2):
  ans+=i
for i in range(1,n,2):
  ans-=i
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = sum(a[1:len(a):2]) - sum(a[0:len(a):2])
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
alice=a[::2]
bob=list(filter(lambda x:x not in alice,a))
print(sum(alice)-sum(bob))

Submission status: Wrong Answer

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

list.sort(reverse = True)

alice = list[0:n:2]
bob = list[1:n:2]

sumA = 0
for a in alice:
    sumA += int(a)

sumB = 0
for b in bob:
    sumB += int(b)

print(sumA-sumB)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(map(int, input().split()), reverse = True)

print(sum(A[: : 2]) - sum(A[: : -2]))

Submission status: Wrong Answer

Solution code:
num_card = int(input())
cards = []
cards = input().split()

cards.sort(reverse=True)
odd = [0]
even = [0]

for draw in range(1, num_card+1):
    if draw % 2 == 1:
        odd.append(int(cards[draw - 1]))
    else:
        even.append(int(cards[draw - 1]))

print(sum(odd) - sum(even))

Submission status: Wrong Answer

Solution code:
num_card = int(input())
cards = []
cards = input().split()

cards.sort(reverse=True)
odd = []
even = []

for draw in range(1, num_card+1):
    if draw % 2 == 1:
        odd.append(int(cards[draw - 1]))
    else:
        even.append(int(cards[draw - 1]))

print(sum(odd) - sum(even))

Submission status: Wrong Answer

Solution code:
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())
c = sorted(list(map(int, input().split())))
print(sum(c[0::2]) - sum(c[1::2]))

Submission status: Wrong Answer

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

a.sort(reverse=True)

alice = 0
bob = 0

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

print (alice-bob)

Submission status: Wrong Answer

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

a.sort(reverse=True)

alice = 0
bob = 0

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

print (alice-bob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted([int(i) for i in input().split()])
ans=sum(a[::2])-sum(a[1::2])
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = sorted(list(map(int,input().split())))
A_card = []
B_card = []
for i in range(n):
        if i%2 == 0:
                A_card.append(A[i])
        else:
                B_card.append(A[i])
print(sum(A_card) - sum(B_card))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
Alice_card = []
Bob_card = []
for i in range(n):
        if i%2 == 0:
                Alice_card.append(A[i])
        else:
                Bob_card.append(A[i])
Alice_total = sum(Alice_card)
Bob_total = sum(Bob_card)
print(abs(Alice_total - Bob_total))

Submission status: Wrong Answer

Solution code:
n = input()
num = [i for i in map(int,input().split(" "))]

num.sort(reverse=True)

A = 0
B = 0
t=0
print(num)
for i in num:
    if t%2==0:
        A+=int(i)
    else:
        B+=int(i)
    t+=1
print(A-B)

Submission status: Wrong Answer

Solution code:
n = input()
num = input().split(" ")

num.sort(reverse=True)

A = 0
B = 0
t=0
for i in num:
    if t%2==0:
        A+=int(i)
    else:
        B+=int(i)
    t+=1
print(A-B)

Submission status: Wrong Answer

Solution code:
num = input().split(" ")

num.sort(reverse=True)

A = 0
B = 0
t=0
for i in num:
    if t%2==0:
        A+=int(i)
    else:
        B+=int(i)
    t+=1
print(A-B)

Submission status: Wrong Answer

Solution code:
num = input().split(" ")

num.sort(reverse=True)

A = 0
B = 0
t=0
for i in num:
    if t%2==0:
        A+=int(i)
        print(i)
        print(t)
    else:
        B+=int(i)
    t+=1
print(A-B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
print(a)
count = 0
alice = 0
bob = 0
a.sort()
f = 0
while(len(a) != 0):
    if f == 0:
        alice = alice + a.pop(-1)
        f = 1
    else:
        bob = bob + a.pop(-1)
        f = 0
print('alice %d' % alice)
print('bob %d' % bob)
print(alice - bob)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

a = list(input("").split(" "))

alice = 0
bob = 0

a = sorted(a,reverse=True)
# print(a)

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

print(alice - bob)

Submission status: Wrong Answer

Solution code:
n = int(input("N = "))

a = list(input("a = ").split(" "))

alice = 0
bob = 0

a = sorted(a,reverse=True)
print(a)

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

print(alice - bob)

Submission status: Wrong Answer

Solution code:
n = int(input("N = "))

a = list(input("a = ").split(" "))

alice = 0
bob = 0

a = sorted(a,reverse=True)
print(a)

for i in range(len(a) - 1):
    alice += int(a[i])
    bob += int(a[i+1])

print(alice - bob)

Submission status: Wrong Answer

Solution code:
n = int(input("N = "))

a = list(input("a = ").split(","))

alice = 0
bob = 0

a = sorted(a,reverse=True)
print(a)

for i in range(len(a) - 1):
    alice += int(a[i])
    bob += int(a[i+1])

print(alice - bob)

Submission status: Wrong Answer

Solution code:
def main(N,xs):
    # type: (int, List[int]) -> None
    xs.sort(reverse=True)
    alice = sum(xs[0::2])
    bob = sum(xs[0:1:2])
    print(alice-bob)
    return

if __name__ == '__main__':
    N = int(input())
    xs = list(map(int,input().split()))
    main(N,xs)

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):
  ans+=(-1)**i * A[i]

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:
a=int(input())
b=[int(i) for i in input().split()]
c=sorted(b)
#print(c)
d=sum(c[0::2])
e=sum(c[1::2])
print(e-d)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=[int(i) for i in input().split()]
c=sorted(b)
d=0
if round(len(c))==1:
	d=c[-1]
else:
	for i in range(round(len(c)/2)):
		d=d+c[-2*i+1]-c[-2*i]
print(d)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=[int(i) for i in input().split()]
c=sorted(b)
#print(c)
d=0
for i in range(round(len(c)/2)):
	d=d+c[-2*i+1]-c[-2*i]
print(d)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
Alice = []
Bob = []
if N % 2 == 0:
    for i in range(N//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
    print(sum(Alice) - sum(Bob))
elif N % 2 == 1 and N != 1:
    for i in range((N-1)//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
        Alice.append(a[-1])
    print(sum(Alice) - sum(Bob))
elif N == 1:
    print(a[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
Alice = []
Bob = []
if N % 2 == 0:
    for i in range(N//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
elif N % 2 == 1 and N != 1:
    for i in range((N-1)//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
        Alice.append(a[-1])
        print(sum(Alice) - sum(Bob))
else:
    print(a[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
a.sort()
a.reverse()
Alice = []
Bob = []
if N % 2 == 0:
    for i in range(N//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
else:
    for i in range((N-1)//2):
        Alice.append(a[i*2])
        Bob.append(a[i*2+1])
        Alice.append(a[-1])
print(sum(Alice) - sum(Bob))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input()
l=[int(_) for _ in input().split()]
print(max(l)-min(l))

Submission status: Wrong Answer

Solution code:
n=input()
a=list(map(str,input().split()))
a.sort(reverse=True)
print(int(eval("+".join(a[::2])))-int(eval("+".join(a[1::2]))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
alice=0
bob=0
#降順ソート
a.sort()
a.reverse()

for i in range(int(n/2)):
        alice+=int(a[2*i])
        bob+=int(a[2*i+1])
if n%2==1:
        alice+=int(a[n-1])

Submission status: Wrong Answer

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

print(alice - bob)

Submission status: Wrong Answer

Solution code:
N=int(input())

x_list=list(map(int,input().split()))
x_list=sorted(x_list)

a,b=0,0

for i in range(N):
    if((i+1)%2!=0):
        a+=x_list[i]
    else:
        b+=x_list[i]

print(a-b)

Submission status: Wrong Answer

Solution code:
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0
sum = 0

for i in range(len(dat)):
     sum = dat[i]
		
print(sum)

Submission status: Wrong Answer

Solution code:
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0
sum = 0

#for i in range(len(dat)):
#      sum = sum + dat[i]
		
print(sum)

Submission status: Wrong Answer

Solution code:
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0

#for i in range(len(dat)):
#         asum = asum + dat[i]
		
print(asum)

Submission status: Wrong Answer

Solution code:
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0
sum=0

for i in range(len(dat)):
     asum =  dat[i]
		
print(asum)

Submission status: Wrong Answer

Solution code:
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0
sum=0

for i in range(len(dat)):
     asum =  dat[i]
		
print(sum)

Submission status: Wrong Answer

Solution code:
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort()
dat.reverse()

asum = 0
bsum = 0
sum=0

for i in range(len(dat)):
     sum =  dat[i]
		
print(sum)

Submission status: Wrong Answer

Solution code:
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort()
dat.reverse()

asum = 0
bsum = 0
sum=0

for i in range(len(dat)):
     sum = sum + i
		
print(sum)

Submission status: Wrong Answer

Solution code:
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort()
dat.reverse()

asum = 0
bsum = 0

#for i in range(len(dat)):
#     if i%2==0:
#          asum = asum + dat[i]
#     else:
#          bsum = bsum + dat[i]
		
print(len(dat))

Submission status: Wrong Answer

Solution code:
dat =list(input().split())

for i in dat:
   i = int(i)

dat.sort()
dat.reverse()

asum = 0
bsum = 0

length = len(dat)

#for i in range(length):
#	if i%2==0:
#		asum = asum + dat[i]
#	else:
#		bsum = bsum + dat[i]
		
print(length)

Submission status: Wrong Answer

Solution code:
dat =list(input().split())

for i in dat:
   i = int(i)

dat.sort()
dat.reverse()

asum = 0
bsum = 0

#for i in range(len(dat)):
#	if i%2==0:
#		asum = asum + dat[i]
#	else:
#		bsum = bsum + dat[i]
		
print(asum-bsum)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
a = 0
b = 0

l.sort()
for i in range(n):
    if i%2 == 0:
        a += l[i]
    else:
        b += l[i]
print(a-b)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = [int(x) for x in input().split()]
alice = bob = []
for i, a in enumerate(sorted(a_list, reverse=True)):
    if i % 2 == 0:
        alice.append(a)
    else:
        bob.append(a)
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.reverse()

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

    else:
        bob += a[i]

print(alice - bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list( map( int, input().split()))
a = sorted(a)
a.reverse()
Alice = 0
Bob = 0
a.append(0)
a.append(0)
print(a)

for i in range(N//2 + 1):
	Alice += int(a[2 * i])  
	Bob += int(a[2 * i + 1])
    
print(Alice -Bob)

Submission status: Wrong Answer

Solution code:
n = input()
a = [int(i) for i in input().split()]
a = sorted(a)
alice = 0
bob = 0
for i in reversed(range(len(a))):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]
print(alice-bob)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
print(a)
alice = sum(a[0::2])
bob = sum(a[1::2])
print(alice-bob)

Submission status: Wrong Answer

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

print(tokuten)

Submission status: Wrong Answer

Solution code:
n = int(input())
card = list(map(int,input().split()))
card = sorted(card,reverse=True)
alice = 0
bob = 0

print(card)
for i,who in enumerate(card):
    if i % 2 ==0:
        alice += who
    else:
        bob += who

print(alice-bob)

Submission status: Wrong Answer

Solution code:
def card_game():
    n = int(input())
    a_li = [int(i) for i in input().split()]
    ans = 0
    turn_switch = True

    a_li.sort()

    for i in a_li:
        if turn_switch:
            ans += i
            turn_switch = False
        else:
            ans -= i
            turn_switch = True

    return ans


if __name__ == '__main__':
    print(card_game())

Submission status: Wrong Answer

Solution code:
def card_game():
    n = int(input())
    a_li = [int(i) for i in input().split()]

    a_li.sort()

    return sum([i for i in a_li[::2]]) - sum([i for i in a_li[1::2]])


if __name__ == '__main__':
    print(card_game())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = sorted(a)

ans = 0
flag = 1
for x in a:
  ans += x * flag
  flag *= -1

print(ans)

Submission status: Wrong Answer

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

c = a[::2]
d = a[1::2]
print(sum(d)-sum(c))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
sorted(a, reverse=True)
alice = 0
bob = 0
flag_alice = True
for num in a:
    if flag_alice:
        alice += num
        flag_alice = False
    else:
        bob += num
        flag_alice = True
print(alice - bob)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
sorted(a, reverse=True)
alice = 0
bob = 0
flag_alice = True
for num in a:
    print(num)
    if flag_alice:
        alice += num
        flag_alice = False
    else:
        bob += num
        flag_alice = True
print(alice - bob)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#utf-8を書かないと日本語で怒られる
n = int(raw_input())
#nを数字にする
l = []
l = map(int, raw_input().split())

# sort
l.sort(reverse=True)
print(l)

# N回のfor文を回して奇数のときはアリスにとらせて偶数ではボブにとらせる
# nは0から回ることに注意（アリスは奇数回目ではない）
alice = 0
bob = 0
for i in range(n):
  if i%2 == 0:
    alice += l[i]
    #print(l[i])
  else:
    bob += l[i]

print(alice-bob)

Submission status: Wrong Answer

Solution code:
number = input().rstrip()

card = input().rstrip().split()

card2 = sorted(card, reverse = True)

alice = 0
bob = 0


for i in range(0, int(number), 2):
    alice += int(card2[i])

for i in range(1, int(number), 2):
    bob += int(card2[i])

print(alice - bob)

Submission status: Wrong Answer

Solution code:
number = input().rstrip()

card = input().rstrip().split()

card2 = sorted(card, reverse = True)

alice = 0
bob = 0


for i in range(0, len(card2), 2):
    alice += int(card2[i])

for i in range(1, len(card2), 2):
    bob += int(card2[i])

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(round(len(a)/2)):
    alice += max(a)
    a.remove(max(a))
    if not a:
        break
    bob += max(a)
    a.remove(max(a))

print(alice-bob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

n_alice = 0
n_bob = 0

for i in range(1, n+1):
    if i % 2:
        n_alice += max(a_list)
        del a_list[np.argmax(a_list)]
    else:
        n_bob += min(a_list)
        del a_list[np.argmin(a_list)]

print(n_alice - n_bob)

Submission status: Wrong Answer

Solution code:
N=int(input())
l=list(map(int,input().split()))
v=sum([l[i] for i in range(0,N,2)])-sum([l[i] for i in range(1,N,2)])
print(v)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
n=int(input())
a=[int(i) for i in input().split()]
alice=0
bob=0
a.sort()
for i in range(n-1,-1,-2):
  alice+=a[i]
  bob+=a[i-1]
print(alice-bob)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
alice = 0
bob = 0


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

print(str(alice - bob))

Submission status: Wrong Answer

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

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

alice = []
bob = []
for na in range(int(n / 2)):
    maxn = max(nums)
    alice.append(maxn)
    nums.remove(maxn)

    maxn = max(nums)
    bob.append(maxn)
    nums.remove(maxn)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(a) for a in input().split()]
A.sort()
d = 0
for a in A[::2]:
  d += a
for a in A[1::2]:
  d -= a
print(d)

Submission status: Wrong Answer

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

print(alice - bob)

Submission status: Wrong Answer

Solution code:
i = int(input())
a = list(map(int, input().split()))
a.sort
a.reverse
alice = a[0::2]
bob = a[1::2]
print(sum(alice) - sum(bob))

Submission status: Wrong Answer

Solution code:
N=input()
a=list(set([int(j) for j in input().split()]))[::-1]
print(sum(a[::2])-sum(a[1::2]))

Submission status: Wrong Answer

Solution code:
N=int( input())
a=list(set([int(j) for j in range(N)]))
print(sum(a[::2])-sum(a[1::2]))

Submission status: Wrong Answer

Solution code:

cordcount = int(input())

n = input()
alice = []
bob = []

lis = n.split(" ")
x = sorted(lis)

# print(x)

alice = x[::-2]

for m in alice:
    x.remove(m)
bob = x
# print(alice,bob)

total = 0
tot = 0

for i in alice:
    total = int(i)+total

for n in bob:
    tot = int(n)+tot

Submission status: Wrong Answer

Solution code:
cordcount = int(input())

n = input()
alice = []
bob = []

lis = n.split(" ")
x = sorted(lis)

print(x)


alice = x[::-2]

for m in alice:
    x.remove(m)
bob = x
print(alice,bob)

total = 0
tot = 0

for i in alice:
    total = int(i)+total

for n in bob:
    tot = int(n)+tot
print(total-tot)

Submission status: Wrong Answer

Solution code:
cordcount = int(input())

n = input()
alice = 0
bob = 0

lis = n.split(" ")
x = sorted(lis)

print(x)

alice = x[::-2]
bob = x[0:-1:2]
print(alice,bob)

total = 0
tot = 0

for i in alice:
    total = int(i)+total

for n in bob:
    tot = int(n)+tot
print(total-tot)

Submission status: Wrong Answer

Solution code:
N = int(input())
numbers = list(map(int, input().split()))
Alice_point = 0
Bob_point = 0

numbers.sort()
print(numbers)

while True:
    try:
        Alice_point += numbers[0]
        Bob_point += numbers[1]
        numbers.remove(numbers[0])
        numbers.remove(numbers[0])
    except IndexError:
        break

print(Alice_point - Bob_point)

Submission status: Wrong Answer

Solution code:
def ret_max(n, list):
    i = 0
    tmp = 0
    max = 0
    for i in range(n):
        if(max < list[i]):
            tmp = i
            max = list[i]
    return tmp

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

j = 0
k = 0
alice = 0
bob = 0
max = 0
lis_elem = len(lis)

for j in range(N):
    lis_elem = len(lis)
    max = lis[ret_max(lis_elem, lis)]
    print("max:",max)
    del lis[ret_max(lis_elem, lis)]
    if(j%2 == 0):
        alice = alice + max
    elif(j%2 == 1):
        bob = bob + max

print(alice - bob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

alice = 0
bob = 0

for i in a:
    alice += max(a)
    a.remove(max(a))
    bob += max(a)
    a.remove(max(a))
    if len(a) == 0:
        break

print(alice - bob)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=input()

A_list = A.split(" ")
map(int,A_list)

A_list.sort()
A_list.reverse()

alice=0
bob=0

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

print(alice-bob)

Submission status: Wrong Answer

Solution code:
N = input()
a = input().split()

a.sort()
a.reverse()

alice = 0
bob = 0

a_num = len(a)

for i in range(a_num):
  if i % 2 == 0:
    alice += int(a[i])
  else:
    bob += int(a[i])

print(alice - bob)

Submission status: Wrong Answer

Solution code:

N = int(input())

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

A.sort()
A.reverse()

Alice = 0
Bob = 0

for i, num in enumerate(A):
    if i//2 == 0:
        Alice += num
    else:
        Bob += num
        
print(Alice - Bob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
a.sort()
bob = 0
i = 0
while 2*i + 1 < len(a):
    bob = bob + a[2*i + 1]
    i += 1

print(sum(a) - 2*bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
a.sort()
a.reverse()
alice = 0
bob = 0
i = 0

while 2 * i + 1 <= len(a) - 1:
    alice = alice + a[2 * i]
    bob = bob + a[2 * i + 1]
    i += 1

print(alice - bob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

cards = map(int, input().split())

sorted_cards = sorted(cards)

Alice = sum(sorted_cards[0::2])
Bob = sum(sorted_cards[1::2])

print(Alice-Bob)

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
inpt = map(int, raw_input().split())
inpt.reverse()

ans = 0

for i in range(0, n):
	ans = ans + inpt[i] * (1 - 2 * (i%2))

print ans