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: Accepted

Solution code:
import subprocess
import gzip, base64, os
import stat

gz = b'H4sIAE6faF0C/+19f3xTVZb4S9OWAKUJP62AUrACFSkNLdAKSksJvAcpIC0/RsFHSFNaTZtM8lKKgoJt1WeMMn7d0Z3dmWFnZl2+Mzs7jrM7g84ILQhFVH6OgiKCP0mpSP2FBYV8z7n3vvS9l7wKO7P7x/djtNycc88995xzzz33x7u57wGHc06KycQpnxTuNg6h348oIXAJwz8SjJMArojrC/+O4kZy6QCnqehKuBJN2s1YK6mF0ZnhLxX+ilIoXJRSoklHMjolNanSNE79KdGk3W5Ok3JcdrwcynqsjmKP1a3SpLZUis/voy2Xwsp1s3LdjF5JuRROkyr6pbK/SoavZHop6WxGN1tFj59FH0lV+H3bSgpvW1miSZsZXbOu3O1QLp278o+NpYtZfUZ2Gc/kV1KlHSZ5a1dPLZzkrZrora0PNU5sLJo6cWphXtCXN5nIZGO0cxcs0dgxi8k8hPkA5h8/8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AYVLLpqo7/TEIez5ImoDvHzrHAYOge5d7FGib+HaGpfkaEgaJgpUghvEiJ6a7eCLrEW9CXVWCgmupHcMUE+JiMzOUJ+BChVSoRv8LBFdHPcpvUZiVdAn1sBIC8bD00I+b9I+h9GOTaFonPJRN1QiURJvhNAEuvW4LjptJU7MHBVTxUXzKwpErz5u1Xnq6nwNCd6CVuppGb12GMd678mrg0GVR/imVHtDwZrEtsXBNh/7faNrdW2DHbtusBY7JhTHqAe6VvvA5lCidJYg2vMKdF0JJ+hJowhGN7C9qNJBz6RHPyMu2I+MOIh+UB0m6OI9nnUs8iWNU4n9HEzurvMnCRAs6IBuSRt3itvrccHiRIL5iQD6w58Eteq6vsdXrXcnVIW0k1YDMpaTPngVQyhZH+kUqia/PE9wIe3YDL5owDjZsDxNPSyTxmww6u7gNBWip84vrYP45IeqfAHXGo8jWXuuhvhVDxFfctfoTEGOsMEY3tgo+j2BoA8iRy0wbMhPdJurHBsgeqBPkBZbCONrna/Kk2RgTKIdG+ESAt2S+rUYDBd7gqE6ZFVWBvh8KtxUdHtYOCcOLmDVaay7JpnhFPhDksOdRAjwtXIR/O4eiFiwMEjiyv51PS1vL9RO+xJHaJxDcDSu/T9YNCUWrJsAAA=='
bin = gzip.decompress(base64.b64decode(gz))
p = os.path.dirname(__file__)
pymain = os.path.join(p, "a.out")
with open(pymain, "wb") as f:
    f.write(bin)
os.chmod(pymain, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
if p == "":
    pymain = "./" + pymain
subprocess.call(pymain)


# compiled by pythran
'''
#pythran export main2()
import numpy as np
def main2():
    stdin = open('/dev/stdin')
    N = int(stdin.readline())
    a = np.empty(N, dtype=np.int64)
    for i, c in enumerate(map(int, stdin.readline().split())):
        a[i] = c
    a = np.sort(a)
    if N & 1:
        print(a[::2].sum() - a[1::2].sum())
    else:
        print(a[1::2].sum() - a[::2].sum())
'''

Submission status: Accepted

Solution code:
N = int(input())
A = [int(n) for n in input().split()]
a = 0
b = 0
for i in range(N):
  n = A.pop(A.index(max(A)))
  if (i % 2):
    b += n
  else:
    a += n
print(a-b)

Submission status: Accepted

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

Submission status: Accepted

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

a=sorted(a, reverse=True)

alice =0
bob   =0

count=0

for i in a:
    if count%2 == 0 :
       alice += i  
    else:
       bob += i
    count+=1

print(alice - bob)

Submission status: Accepted

Solution code:
N = int(input())
cards = list(map(int, input().split()))
cards.sort()
alice, bob = 0, 0
while True:
    alice += cards.pop()
    if not cards:
        break
    bob += cards.pop()
    if not cards:
        break
print(alice - bob)

Submission status: Accepted

Solution code:
N = int(input())

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

a.reverse()

A = []
B = []

for x in range(0,N,2):
    A.append(a[x])
    
        
for y in range(1,N,2):
    B.append(a[y])
    
print(sum(A)-sum(B))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
list = list(map(int,input().split()))
list_alice = []
list_bob = []
list.sort(reverse=True)
for i in range(N):
    if i % 2 ==0:
        list_alice.append(list[i])
    else:
        list_bob.append(list[i])
print(sum(list_alice) - sum(list_bob))

Submission status: Accepted

Solution code:
n = int(input())
As = sorted(list(map(int, input().split())))
if n % 2 == 1:
    As = [0] + As
print(sum(As[1::2]) - sum(As[::2]))

Submission status: Accepted

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

Alice = 0
Bob = 0

number.sort(reverse=True)

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

print(Alice - Bob)

Submission status: Accepted

Solution code:
n = int(input())
nums = sorted([int(tok) for tok in input().split()], reverse = True)

alice = sum([nums[i] for i in range(0, n, 2)])
bob = sum([nums[i] for i in range(1, n, 2)])

print(alice - bob)

Submission status: Accepted

Solution code:
n=int(input())
li=map(int,input().split())
li=sorted(li)[::-1]
A=0
B=0
for k in range(n//2):
  A += li[2*k]
  B += li[2*k+1]
if n % 2 ==1:
  A += li[n-1]
print(A-B)

Submission status: Accepted

Solution code:
N = int(input())
arr = list(map(lambda a: int(a), input().split()))
ordered_arr = sorted(arr)
total_a, total_b = 0, 0

for n in range(N):
    if n%2 == 0:
        total_a += ordered_arr[n]
    else:
        total_b += ordered_arr[n]

print(abs(total_a-total_b))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)

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

print(Alice-Bob)

Submission status: Accepted

Solution code:
n = int(input())
a = sorted([int(x) for x in input().split()], reverse = True)
alice = 0
bob = 0
for x in range(n):
    if x % 2 == 0:
        alice += a[x]
    else:
        bob += a[x]

print(alice - bob)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    for j in range(N-1,i,-1):
        if a[j] < a[j-1]:
            a[j], a[j-1] = a[j-1], a[j]

if N % 2 == 0:
    for k in range(N//2):
        Alice += a[(2*k)+1]
        Bob += a[2*k]
        

else:
    for k in range(N//2):
        Alice += a[2*k]
        Bob += a[2*k+1]
    Alice += a[N-1]

print(Alice-Bob)

Submission status: Accepted

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

for i in range(N):
    if i%2==0:
        count += nums[i]
    else:
        count -= nums[i]
        
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(alice - bob)

Submission status: Accepted

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

a = sorted(a, reverse=True)
al = 0
bo = 0
for i, aa in enumerate(a):
    if i %2 == 0:
        al += aa
    else:
        bo += aa
print(al -bo)

Submission status: Accepted

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

Submission status: Accepted

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 i%2 == 0:
    Alice += A[i]
  else:
    Bob += A[i]
ans = Alice - Bob
print(ans)

Submission status: Accepted

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

for i in range(1,N,2):
  a[i] *= -1
print(sum(a))

Submission status: Accepted

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

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

print(alice-bob)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def test():
    n = int(input())
    a = list(map(int,input().split()))
    flag = 0
    alice = 0; bob = 0
    for i in range(n):
        if flag == 0:
            alice += max(a)
            a.remove(max(a))
            flag = 1
        elif flag == 1:
            bob += max(a)
            a.remove(max(a))
            flag = 0
    print(alice-bob)


if __name__ == "__main__":
    test()

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import sys
N = int(sys.stdin.readline().rstrip())
p = list(map(int, sys.stdin.readline().rstrip().split()))
p = sorted(p, reverse = True)
A = 0
B = 0
for i in range(N):
    if i%2 == 0:
        A += p[i]
    else:
        B += p[i]
print(A - B)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    A.sort(reverse=True)
    is_alice_turn = True
    ans = 0
    for i in range(n):
        if is_alice_turn:
            ans += A[i]
        else:
            ans -= A[i]
        is_alice_turn = not is_alice_turn
    print(ans)

input = lambda: stdin.readline().rstrip()
main()

Submission status: Accepted

Solution code:
N=int(input())

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

b.sort(reverse=True)

alice=[]
bob=[]

for i in range(N):
    if i==0:
        alice.append(b[i])
    elif i%2==0:
        alice.append(b[i])
    else :
        bob.append(b[i])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
nums = sorted(list(map(int, input().split())), key=lambda x: -x)
alice = 0
bob = 0
for i, num in enumerate(nums):
    if i % 2 == 0:
        alice += num
    else:
        bob += num
print(alice - bob)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc088/tasks/abc088_b
# B - Card Game for Two

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

a_list = sorted(a_list, reverse=True)
p_alice = sum(a_list[::2])
p_bob = sum(a_list[1::2])
ans = p_alice - p_bob
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import numpy as np


#a, b, c, x = map(int, [input() for i in range(4)])
#z = list(map(int, input().split()))
#n, a, b = map(int, input().split())

#print(len(z))
#for i in z:
#    print(i)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(list(map(int, input().split())), reverse = True)
ali = 0
bob = 0
if n % 2 == 1:
    ali = l[n-1]
for i in range(n//2):
    ali += l[i*2]
    bob += l[i*2+1]
print(ali - bob)

Submission status: Accepted

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

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

print(Alice-Bob)