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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
cards = []
for i in range(n):
  cards.append(int(input()))

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

Submission status: Runtime Error

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

for i in range(N):
    m = max(A)
    A.remove(m)
    if i % 2 == 0:
        alice += m
    else:
        bob += m
print(alice - bob)

Submission status: Runtime Error

Solution code:
N = int(input())
A = map(int, input.split())
alice, bob = 0, 0

for i in range(N):
    m = max(A)
    A.remove(m)
    if i % 2 == 0:
        alice += m
    else:
        bob += m
print(alice - bob)

Submission status: Runtime Error

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

while True:
    if len(LIST)==0:
        break
    Alice = Alice + LIST.pop()
    Bob = Bob + LIST.pop()

print(Alice - Bob)

Submission status: Runtime Error

Solution code:
N=int(input())
cardlist=list(map(int,input().split())).sort(reverse=True)
Alist=cardlist[0:,2]
Blist=cardlist[1:,2]
Asum=sum(Alist)
Bsum=sum(Blist)
print(Asum-Bsum)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#カードの総数
N = int(input())
#それぞれのカードのリスト
a = list(map(int, input().split()))
a = a.sort
#aliceのリスト
alice_list = []
#bobのリスト
bob_list = []

if N%2 == 0:
    for i in range(N):
        if i%2 == 0:
            alice_list.append(a[i])
        else:
            bob_list.append(a[i])

else:
    for i in range(N):
        if i%2 == 0:
            bob_list.append(a[i])
        else:
            alice_list.append(a[i])

alice_num = sum(alice_list)
bob_num = sum(bob_list)
ans = alice_num - bob_num

Submission status: Runtime Error

Solution code:
    n = int(input())
     
    num_list = sorted([ int(v) for v in input().split() ],reverse = True)
     
    a_sum, b_sum = 0, 0
     
    for i in range(n):
      if i % 2 == 0:
        a_sum += num_list[i]
      else:
        b_sum += num_list[i]
     
    print(a_sum-b_sum)

Submission status: Runtime Error

Solution code:
n = int(input())

num_list = [ int(v) for v in input().split() ]

a_sum, b_sum = 0, 0

for i in range(n):
  if i % 2 == 0:
    a_sum += num_list[i]
  else:
    b_sum += num_list[i]

print(a-b)

Submission status: Runtime Error

Solution code:
*a,=open(0);n,a=map(int,a);print(sum(a[0::2])-sum(a[1::2]))

Submission status: Runtime Error

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

a.sort(reverce = True)

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

print(alice - bob)

Submission status: Runtime Error

Solution code:
n = int(input())
cards = [int(i) for i in input().split()]
cards.reverse()
a = 0
b = 0
for i, num in enumerate(cards):
    if(i % 2 == 0):
        a = a + num
    else:
        b = b + num
print a - b

Submission status: Runtime Error

Solution code:
n = int(input())
cards = [int(i) for i in input().split()]
cards.sort(reverse=True)
a = 0
b = 0
for i, num in enumerate(cards):
    if(i % 2 == 0):
        a = a + num
    else:
        b = b + num
print a - b

Submission status: Runtime Error

Solution code:
n = int(input())
cards = [int(i) for i in input().split()]
sorted = cards.sort(reverse=True)
a = 0
b = 0
for i, num in enumerate(sorted):
    if(i % 2 == 0):
        a = a + num
    else:
        b = b + num
print a - b

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
if len(A) & 1:
  A.append(0)
A.sort()
print(sum([A[i+1]-A[i] for i in range(0, A, 2)]))

Submission status: Runtime Error

Solution code:
n = int(input())
m = map(int, input().split())
m.sort(reverse=True)
a = 0
b = 0
t = True
for i in m:
  if t:
    a += i
  else:
    b += i
  t = True if t else False
print(a-b)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()
a = map(int, input().split())
new_list = sorted(a, reverse=True)
sum = 0
for i,n in enumerate(new_list):
        if i % 2 == 0:
                sum += n
        else:
                sum -= n
print(sum)
~

Submission status: Runtime Error

Solution code:
def main():
  size = input()
  a = map(int, input().split())
  a = merge_sort(a)
  
  alice_res = 0
  bob_res = 0
  
  for i in range(len(a)):
    if i%2 == 0:
      alice_res += a[i]
    else:
      bob_res += a[i]
 
  print(alice_res-bob_res)
  

def merge_sort(array):
  if len(array)<=1:
    return array
  
  spl_size = len(array)//2
  
  left_list = merge_sort(array[:spl_size])
  right_list = merge_sort(array[spl_size:])
  
  return merge_list(left_list, right_list)


def merge_list(left_list, right_list):
  left_index = 0
  right_index = 0
  sorted_list = []
  
  while left_index<len(left_list) and right_index<len(right_list):
    if left_list[left_index] < right_list[right_index]:
      sorted_list.append(right_list[right_index])
      right_index+=1
    else:
      sorted_list.append(left_list[left_index])
      left_index+=1
      
  if left_index == len(left_list):
    sorted_list.extend(right_list[right_index:])
  if right_index == len(right_list):
    sorted_list.extend(left_list[left_index:])
      
  return sorted_list
    
                          
main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

a.sort(reverse=True)
print(sun(a[::2])-sun(a[1::2]))

Submission status: Runtime Error

Solution code:
n = int(input())
A = list(map(int,input().split()))
A_0 = A.sort(reverse=True)
swt = 0
Alice_point = 0
Bob_point = 0

for i in range(n):
    if swt == 0:
        Alice_point += A_0[i]
        swt = 1
    else:
        Bob_point += A_0[i]
        swt = 0
print(Alice_point - Bob_point)

Submission status: Runtime Error

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

a.sort(reverse=True)
alice = a[0::2]
bob = a[1::2]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reversed=True)
alice = 0
bob = 0
for index, a in enumerate(A):
  if (index % 2)  == 0:
    alice += a
  else:
    bob += a
print(alice - bob)

Submission status: Runtime Error

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

Alice = 0
Bob = 0

for i in range(n):
    current_max = max(num_list)
    if i % 2 == 0:
        Alice += current_max
    else:
        Bob += current_max
    a_list.remove(current_max)

print(Alice - Bob)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())

card = list(map(int, input().split()))
sorted_card = card.sort(reverse=True)

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: Runtime Error

Solution code:
N = int(input())

card = list(map(int, input().split())).sort(reverse= True)

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

a.sort(reverse=True)

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

Submission status: Runtime Error

Solution code:
N = int(input())
Ai = input().split()
Ai = [int(n) for n in Ai]
Ai = sorted(Ai, reverse=True)
Alice = 0
Bob = 0
i = 0
while True:
  if i+1 <= N:
    Alice += Ai[i]
    Bob = Alice[i+1]
  if i == N:
    Alice += Ai[i]
  if i > N:
    break
  i = i + 2

print(Alice - Bob)

Submission status: Runtime Error

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

for i in range(N):
  if i%2==1:
    S+=a[i]
  else:
    S-=a[i]
print(S)

Submission status: Runtime Error

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

for i in range(N):
  if i%2==1:
    S+=a2[i]
    a.remove(max(a))
  else:
    S-=a2[i]
print(S)

Submission status: Runtime Error

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

for i in range(N):
  if i%2==1:
    S+=a2[i]
    a.remove(max(a))
  else:
    S-=a2[i]
print(S)

Submission status: Runtime Error

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

for i in range(N):
  if i%2==1:
    S+=max(a)
    a.remove(max(a))
  else:
    S-=max(a)
    a.remove(max(a))
print(S)

Submission status: Runtime Error

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

for i in range(N):
  if i%2=1:
    S+=max(a)
    a.remove(max(a))
  else:
    S-=max(a)
    a.remove(max(a))
print(S)

Submission status: Runtime Error

Solution code:
N=int(input())
a=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: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
a=input().split()
alice=0
bob=0

a2=sorted(a,reverse=true)

alice=sum(a2[1::2])
bob=sum(a2[0::2])
print(alice-bob)

Submission status: Runtime Error

Solution code:
N=int(input())
a=input().split()
alice=0
bob=0
while len(a) !=0:
  alice+=max(a)
  a.remove(max(a))
  if len(a) !=0:
    bob+=max(a)
    a.remove(max(a))
  else: break
print(alice-bob)

Submission status: Runtime Error

Solution code:
N=int(input())
a=input().split()
alice=0
bob=0
while len(a) !=0:
  alice+=max(a)
  a.remove(max(a))
  bob+=max(a)
  a.remove(max(a))
print(alice-bob)

Submission status: Runtime Error

Solution code:
N=int(input())
a=input().split()
alice=0
bob=0
while len(a) !=0:
  alice+=max(a)
  a.remove(max(a))
  bob+==max(a)
  a.remove(max(a))
print(alice-bob)

Submission status: Runtime Error

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

while len(a) !=0:
  alice+=max(a)
  a.remove(max(a))
  bob+==max(a)
  a.remove(max(a))
print(alice-bob)

Submission status: Runtime Error

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

alice_list = []
bob_list = []

for i in range(len(a_list) - 1):
    max_a = max(a_list)
    a_list = a_list.remove(max_a)

    if i % 2 == 0:
        alice_list.append(max_a)
    else:
        bob_list.append(max_a)

answer = sum(alice_list) - sum(bob_list)
print(answer)

Submission status: Runtime Error

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.appemd(li[i])
  else:
    if i%2==0:
      b.append(li[i])
    else:
      a.append(li[i])
print(sum(a)-sum(b))

Submission status: Runtime Error

Solution code:
n=int(input())
alice=[]
bob=[]
l=list(map(int,input().split()))
while len(l)>0:
    alice.append(max(l))
    l.remove(max(l))
    bob.append(max(l))
    l.remove(max(l))

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

Submission status: Runtime Error

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

alice = 0
bob = 0

for i in range(0,N):
  if i %2 == 0:
    alice += card_num[i]
  else:
    bob   += card_num[i+1] 
ans = int(alice - bob)

print(ans)

Submission status: Runtime Error

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

A.sort(reverse=True) #これで実行される(new_A = A.sortとかしても返り値はnon-type)

ans = 0
for i in range(1, N+1):
    if i % 2 == 0:
        ans += A[i]
    if i % 2 == 1:
        ans -= A[i]

print(ans)

Submission status: Runtime Error

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

new_A = A.sort(reverse=True)

ans = 0
for i in range(1, N+1):
    if i % 2 == 0:
        ans += new_A[i]
    if i % 2 == 1:
        ans -= new_A[i]
print(ans)

Submission status: Runtime Error

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

new_A = A.sort(reverse=True)

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

print(ans)

Submission status: Runtime Error

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

new_A = A.sort(reverse=True)

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

print(ans)

Submission status: Runtime Error

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

A = A.sort(reverse=True)

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

print(ans)

Submission status: Runtime Error

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

A = A.sort(reverse=True)

ans = 0
for i in range(len(A)):
    if i % 2 == 0:
        ans += A[i]
    elif i % 2 == 1:
        ans += -A[i]

print(ans)

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/abc088/tasks/abc088_b

import itertools
import collections
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    a_sum = sum([a for a in range(A,2)])
    b_sum = sum([a for a in range(1, A,2)])
    print(a_sum - b_sum)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

a.sort(reverse=True)

alice = 0
bob = 0

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

print (alice-bob)

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    int a[110];
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
       

    sort(a,a+n,greater<int>());//a[0:n]
    int Alice=0;
    int Bob=0;
    for(int i=0;i<n;i++){
        if(i%2==0){//even Alice
            Alice += a[i];
        }
        else{
            Bob += a[i];
        }
    }
    cout<<Alice-Bob<<endl;

}

Submission status: Runtime Error

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

a.sort(reverse = True)

su = 0

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(n) for n in input().split()].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: Runtime Error

Solution code:
n = int(input())
ls = list(map(int,input().split()))
A = 0
B = 0
lsn = sorted(ls,reverse = True)
if n%2 == 1:
  lsn = lsn.append(0)
for i in range(0,len(lsn),2):
  A += lsn[i]
  B += lsn[i+1]
print(A-B)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.soat(reverse=True)
A = sum([i for i in a[::2]])
B = sum([j for j in a[1::2]])
print(A - B)

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/abc088/tasks/abc088_b?lang=ja

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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

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

print(alice_score - bob_score)
# https://atcoder.jp/contests/abc088/tasks/abc088_b?lang=ja

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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

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

print(alice_score - bob_score)

Submission status: Runtime Error

Solution code:
n = input()
nums = list(map(int, input().split())).sort(reverse=True)
result = 0
for i, v in enumerate(nums):
    result += (1 if i % 2 == 0 else -1) * v
print(result)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
b=0
c=0
if n%2==0:
    for i in range(n//2):
        b+=a[2*i]
        c+=a[2*i+1]
else:
    for i in range(n//2):
        b+=a[2*i]
        c+=a[2*i+1]
    b+=a[n]
if b>c:
    print(b-c)
else:
    print(c-a)

Submission status: Runtime Error

Solution code:
スコード
Copy
### coding: UTF-8
 
#import math
#import random as rd
#import numpy as np
 
 
n=int(input())
line=list(map(int,input().split( )))
 
line=sorted(line)
 
#print(line)
 
s=sum([line[-(i+1)] for i in range(n) if i%2==0])-sum([line[-(i+1)] for i in range(n) if i%2!=0])
 
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0

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

Submission status: Runtime Error

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

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0

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

Submission status: Runtime Error

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

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0

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

Submission status: Runtime Error

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: Runtime Error

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: Runtime Error

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

for i in dat:
	i = int(i)

dat.sort(reverse=True)

int asum = 0
int bsum = 0

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

Submission status: Runtime Error

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: Runtime Error

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)):
     if i % 2 == 0:
         asum = asum + dat[i]
      else:
         bsum = bsum + dat[i]
		
print(asum-bsum)

Submission status: Runtime Error

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)):
     asum =  asum + dat[i]
		
print(sum)

Submission status: Runtime Error

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 + dat[i]
		
print(sum)

Submission status: Runtime Error

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)):
     bsum = bsum + dat[i]
		
print(bsum)

Submission status: Runtime Error

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: Runtime Error

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

for i in dat:
	i = int(i)

dat.sort()
dat.reverse()

asum = 0
bsum = 0

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

Submission status: Runtime Error

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: Runtime Error

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: Runtime Error

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(0)

Submission status: Runtime Error

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(lengrh)

Submission status: Runtime Error

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(asum-bsum)

Submission status: Runtime Error

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: Runtime Error

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: Runtime Error

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)):
	if (i%2==0):
		asum = asum + dat[i]
	else:
		bsum=bsum + dat[i]
		
print(asum-bsum)

Submission status: Runtime Error

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)):
	if i%2==0:
		asum = asum + dat[i]
	else:
		bsum=bsum + dat[i]
		
print(asum-bsum)

Submission status: Runtime Error

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

for i in dat:
      i = int(i)

dat.sort(reverse=True)

asum=0
bsun=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: Runtime Error

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

for i in dat:
      i = int(i)

dat.sort(reverse=True)

asum=0
bsun=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: Runtime Error

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

for i in dat:
      dat[i] = int(dat[i])

dat.sort(reverse=True)

asum=0
bsun=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: Runtime Error

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

dat.sort(reverse=True)

asum=0
bsun=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: Runtime Error

Solution code:
times = int(input())
ans = 0
type = 1
num = map(int,input().split(" "))
num.sort(reverse=Ture)
for i in num:
    if type % 2:
        ans += i
    else:
        ans -= i
    type += 1
    
print(ans)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


int main() {
    cin.tie();
    ios::sync_with_stdio(false);

    // input
    int N;
    cin >> N;
    vector<int> vec(N);
    REP(i, N) cin >> vec.at(i);
    
    // calculation
    int A = 0, B = 0;
    sort(vec.begin(), vec.end(), greater<int>());  // int big -> small
    
    for (int j = 0; j < N; ++j) {
        if (j%2 == 0) {
            A += vec[j];
        } else{
            B += vec[j];
        }
    }
    
    cout << A - B << "\n";
    
    return 0;
}

Submission status: Runtime Error

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
A = 0
B = 0
while len(ar) != 0:
  A += max(ar)
  ar.remove(max(ar))
  B += max(ar)
  ar.remove(max(ar))
print(A - B)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list( map( int, input().split()))
a = sorted(a)
a.reverse()
Alice_Bob = o
Bob = 1

for i in a:
	Alice_Bob += a * Bob  
	Bob *= -1
    
print(Alice_Bob)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n=int(input())
s=[int(input()) for _ in range(n)]
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)