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 = list(map(int,input().split()))
a.sort()
A = sum(a[1::2])
B = sum(a[2::2])

print(A-B)

Submission status: Wrong Answer

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

one =[]
two =[]
count = 0
if N%2 ==0:
  while count <= N-1:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
else:
  while count <= N-2:
    one.append(max(B))
    B.remove(max(B))
    two.append(max(B))
    B.remove(max(B))
    count +=2
  one.append(max(B))
  B.remove(max(B))
print(one)
print(two)
print(sum(one)-sum(two))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

input()
data = sorted(map(int, input().split(' ')))


s = 0
for i, n in enumerate(data):
    s = s + int(math.pow((-1),(i%2)))*n
print(s)

Submission status: Wrong Answer

Solution code:

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

sort_a_list = sorted(a_list)

alice = 0
bob = 0

for i, a in enumerate(sort_a_list):
    if i % 2 == 0:
        alice += a
    else:
        bob += a

print(alice - bob)

Submission status: Wrong Answer

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

sort_a_list = sorted(a_list)

alice_list = []
bob_list = []

for i, a in enumerate(sort_a_list):
    index = i + 1
    if i % 2 == 1:
        alice_list.append(a)
    elif i % 2 == 0:
        bob_list.append(a)

print(sum(alice_list) - sum(bob_list))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(input().split())
a.sort(reverse=True)
alice = 0
bob = 0
for index, item in enumerate(a):
    if int(index) == 0 or int(index) % 2 == 0:
        alice += int(item)
    else:
        bob += int(item)
print("{}".format(alice - bob))

Submission status: Wrong Answer

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

Alice = 0
Bob = 0
A.sort(reverse=True)

if N%2 == 0:
    for i in range(int(N/2)):
        Alice += A[2*i]
        Bob += A[2*i+1]
        print(Alice-Bob)
        
else:
    for i in range(int((N-1)/2)):
        Alice += A[2*i]
        Bob += A[2*i+1]
    Alice += A[-1]
    print(Alice-Bob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A=B=I=0
for i in a:
    if I %2:B+=i
    else:A+=i
    I+=1

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

Submission status: Wrong Answer

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

a[:n].sort(reverse=True)

A=B=I=0
for i in a:
    if I %2:B+=i
    else:A+=i
    I+=1

print(A-B)
# other
# print(sum(a[::2]) - sum(a[1::2]))

Submission status: Wrong Answer

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

sortedList = sorted(li, reverse=True)
print(sortedList)

alice = 0
bob = 0
turn = 1

while(len(sortedList)):
  if turn % 2 == 1:
    alice += sortedList.pop(0)
  else:
    bob += sortedList.pop(0)
  
  turn += 1

print(alice - bob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a = int(input())  # Nを入力
b = input()  # a1,a2...anを入力
b = map(int, b.split())  # a1,a2...anをint型でリストに入れる
b = sorted(b)  # 大きい順に並べる b = b[::-1]  # リストの要素の順番を逆転する
c = b[::2]  # Aliceのとる要素を抽出
c_number = len(c)
d = b[1::2]  # Bobのとる要素を抽出
d_number = len(d)
c_sum = 0
d_sum = 0
for i in range(c_number):
    c_sum += c[i] # Aliceのとる要素の合計
for g in range(d_number):
    d_sum += d[g]  # Bobのとる要素の合計
print(c_sum - d_sum)  # 差分を出力

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
A = 0 #Aliceのscore
B = 0 #Bobのscore

a.sort()

for i in range(int(n/2)):
  A += a[-i-1]
  B += a[i]

print(A-B)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = []
for i in range(0,N,2):
  B.append(A[i])
print(abs(sum(A)-sum(B)*2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
A.reverse()
if N % 2 == 0:
    print(sum(A[: N // 2]) - sum(A[N // 2 :]))
else:
    print(sum(A[: N // 2 + 1]) - sum(A[N // 2 + 1 :]))

Submission status: Wrong Answer

Solution code:
for_num = int(input())
nums = input()
nums = nums.split()
nums = sorted(nums,reverse=True)

A = 0
B = 0

for i in range(0,for_num):
  num = int(nums[i])
  if i%2 == 0:
    A += num
  else:
    B += num
print(A-B)

Submission status: Wrong Answer

Solution code:
for_num = int(input())
nums = input()
nums = nums.split()
nums = sorted(nums,reverse=True)
print(nums)
A = 0
B = 0

for i in range(0,for_num):
  num = int(nums[i])
  if i%2 == 0:
    A += num
  else:
    B += num
print(A-B)

Submission status: Wrong Answer

Solution code:
for_num = int(input())
nums = input()
nums = nums.split()
nums.sort(reverse=True)
A = 0
B = 0

for i in range(0,for_num):
  num = int(nums[i])
  if i%2 == 0:
    A += num
  else:
    B += num
print(abs(A-B))

Submission status: Wrong Answer

Solution code:
for_num = int(input())
nums = input()
nums = nums.split()
nums.sort(reverse=True)
A = 0
B = 0

for i in range(0,for_num):
  num = int(nums[i])
  if i%2 == 0:
    A += num
  else:
    B += num
print(A-B)

Submission status: Wrong Answer

Solution code:
card_num = int(input())
nums = input()
nums = nums.split()
num_list = []
for i in range(0,card_num):
  num = int(nums[i])
  num_list.append(num)
print(max(num_list)-min(num_list))

Submission status: Wrong Answer

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

alice = 0
bob = 0
an.sort()
an.reverse()
print(an)
for i,v in enumerate(an):
    if i % 2 ==0:
        alice += v
    else:
        bob += v

print(alice - bob)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import numpy
import scipy

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

A_sort = sorted(A, reverse=True)
print(A_sort)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n = int(input())
cards = sorted(list(map(int, input().split())), reverse=True)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n = int(input())
cards = sorted(list(map(int, input().split())))

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
sum_ = sum(a)
sorted(a)
alice = 0
for i in range(len(a)):
    if i % 2 == 0:
        alice += a[-i-1]
print(2*alice - sum_)
#print(alice)

Submission status: Wrong Answer

Solution code:
a = int(input())  
b = input()  
b = map(int, b.split())
print(type(b))
b = sorted(b)
b = b[::-1]
c = b[::2]
c_number = len(c)
d = b[1::2]
d_number = len(d)
c_sum = 0
d_sum = 0
for i in range(c_number):
    c_sum += c[i]

for g in range(d_number):
    d_sum += d[g]

print(c_sum - d_sum)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a = int(input())  # Nを入力
b = input()  # a1,a2...anを入力
b = map(int, b.split())
print(type(b))
b = sorted(b)
b = b[::-1]
c = b[::2]
c_number = len(c)
d = b[1::2]
d_number = len(d)
c_sum = 0
d_sum = 0
for i in range(c_number):
    c_sum += c[i]

for g in range(d_number):
    d_sum += d[g]

print(c_sum - d_sum)

Submission status: Wrong Answer

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

a.sort()

alice = 0
bob = 0

for idx, val in enumerate(a):
    if idx % 2 == 0:
        alice += val
    else:
        bob += val

print(alice - bob)

Submission status: Wrong Answer

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

a.sort(reverse=True)

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

print("{}".format(Alice - Bob))

Submission status: Wrong Answer

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

a.sort(reverse=True)

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

print("{}".format(Alice - Bob))

Submission status: Wrong Answer

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

list.sort()

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

print("{}".format(Alice - Bob))

Submission status: Wrong Answer

Solution code:
x = int(input())
y = [int(i) for i in input().split()]
y.sort(reverse=True)
a = 0
b = 0
for i in range(1, x+1):
    if(i%2) != 0:
        a += y[i-1]
        print(y[i-1])
    else:
        b += y[i-1]
print(a-b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A.sort(reverse=True)
print(A)
print((sum(A[::2])) - sum(A[1::2]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N):
    if i % 2 == 0:
        alice += sorted_a[i]
    else:
        bob += sorted_a[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 i % 2==1:
    alice+=a[i]
  else:
    bob+=a[i]
print(alice-bob)

Submission status: Wrong Answer

Solution code:
n = input()
li = list(map(int,input().split()))
li.sort(reverse=True)
Alice = 0
Bob = 0
count = 1
for i in li:
    if count % 2:
        Alice += i
        count += 1
        print(count,Alice)
    else:
        Bob += i
        count += 1
        print(count,Bob)
print(Alice - Bob)

Submission status: Wrong Answer

Solution code:
n = input()
li = list(map(int,input().split()))
li.sort()
count = 1
Alice = 0
Bob = 0
for i in li:
    if count % 2:
        Alice += i
        count += 1
    else:
        Bob += i
        count += 1
print(Alice - Bob)

Submission status: Wrong Answer

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

c=0
d=0

for i in range(len(b)):
    if i%2 == 0:
        c += b[i]
    else:
        d += b[i]

print(c - d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
a = list(map(int, input().split()))
a= sorted(a, reverse=True)
print(a)
ans =0
for i in a:
    if i%2 == 0:
        ans += i
    elif i%2 ==1:
        ans -= i
print(ans)

Submission status: Wrong Answer

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

length = len(cards)
mid = 0
if length % 2 == 0:
    mid = int(length / 2)
else:
    mid = int(length / 2) + 1

print(sum(cards[0:mid]) - sum(cards[mid:]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(alice-bob)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

a = list(map(int, input().split()))
Alice = 0
Bob = 0

# print(a)

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

print(Alice -Bob)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
sum1 = 0
sum2 = 0
sum3 = 0
sum4 = 0
if n % 2 == 0:
	for s in range(n):
		if s % 2 == 0:
			sum1 += a[s]
		else:
			sum2 += a[s]
	print(max(sum1, sum2) - min(sum1, sum2))
else:
	for s in range(n):
		if s % 2 == 0:
			sum1 += a[s]
		else:
			sum2 += a[s]
	sum3 = sum1 - a[0]
	sum4 = sum2 + a[0]
	ans1 = max(sum1, sum2) - min(sum1, sum2)
	ans2 = max(sum3, sum4) - min(sum3, sum4)
	print(max(ans1, ans2))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

a_inputs = input().split()

a = np.zeros(N)
for i in range(N):
  a[i] = int(a_inputs[i])
  
a = np.sort(a)[::-1]

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

print(alice - bob)

Submission status: Wrong Answer

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

print(Alice-Bob)

Submission status: Wrong Answer

Solution code:
N=int(input())
cards = list(map(int, input().split()))
cards.reverse()
Alice=sum(cards[0:N:2])
Bob=sum(cards[1:N:2])
print(Alice-Bob)

Submission status: Wrong Answer

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

ans = 0
bob = []
alice = []
a = sorted(a, reverse=True)
for i, card in enumerate(a):
    if i%2 == 0:
        alice.append(int(card))
    else:
        bob.append(int(card))

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

Submission status: Wrong Answer

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

card_values_sorted = sorted(card_values, reverse=True)
print(card_values_sorted)

Alice_score = 0
Bob_score = 0
for i in range(N):
    if i%2 == 0:
        Alice_score += card_values_sorted[i]
    else:
        Bob_score += card_values_sorted[i]

print(Alice_score - Bob_score)

Submission status: Wrong Answer

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

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: Wrong Answer

Solution code:
n=int(input())
li=map(int,input().split())
li=sorted(li)
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(B-A)

Submission status: Wrong Answer

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)
print(a-b)

Submission status: Wrong Answer

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

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

print(alice - bob)

Submission status: Wrong Answer

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

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

print(alice - bob)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
lista=list(map(int,input().split()))
lista.sort()
alice=list()
bob=list()
for i in range(n):
    if i%2==0:
        alice.append(lista[i])
    else: 
        bob.append(lista[i])

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a_list=list(input().split())
a_list.sort(reverse=True)
a = 0
b = 0
for i in range(n):
    if i % 2 == 0:
        a += int(a_list[i])
    elif i % 2 == 1:
        b += int(a_list[i])
print(a-b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a_list=list(input().split())
 
a = 0
b = 0
a_list_sorted = a_list.sort(reverse=True)
 
for i in range(len(a_list)):
    if i % 2 == 0:
        a += int(a_list[i])
#         print(a)
    else:
        b += int(a_list[i])
#         print(b)
print(a-b)

Submission status: Wrong Answer

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

a = 0
b = 0
a_list_sorted = a_list.sort(reverse=True)

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

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:
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 = input()

a = a.split()


for i in range(n):
	a[i] = int(a[i])
	
a.reverse()


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

Submission status: Wrong Answer

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

a = a.split()

alice = 0
bob = 0
ans = 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:
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort()
    sw = 0
    alice = 0
    bob = 0
    for i in a:
        if sw == 0:
            alice += i
            sw = 1
        else:
            bob += i
            sw = 0
    print(alice-bob)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

print(alice-bob)

Submission status: Wrong Answer

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

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

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 (0,n):
    if i % 2:
        bob += a[i]
    else:
        alice += a[i]

print(alice - bob)
print(a)

Submission status: Wrong Answer

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

apoint = 0
bpoint = 0
while True:
	apoint = max(cards)
	cards.remove(max(cards))

	if len(cards) == 0:
		break

	bpoint = max(cards)
	cards.remove(max(cards))

	if len(cards) == 0:
		break

dif = apoint - bpoint
print(dif)

Submission status: Wrong Answer

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

c = 0
a.sort(reverse=True)
for i in range(N):
  if i//2 == 0:
    c += a[i]
  else:
    c -= a[i]
print(a[i])

Submission status: Wrong Answer

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

a = 0
b = 0

card.sort(reverse=True)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
cards_number = input()
numbers = list(map(int, cards_number.split()))
ordered_numbers = sorted(numbers, reverse=True)

even_indexes = list(num for num in range(0, N) if num % 2 == 0)
odd_indexes = list(num for num in range(0, N) if num % 2 == 1)
alice_cards = list(ordered_numbers[even_index] for even_index in even_indexes)
bob_cards = list(ordered_numbers[odd_index] for odd_index in odd_indexes)

alice_point = sum(alice_cards)
bob_point = sum(bob_cards)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
 
if N%2 == 0:
  print(N/2)
else:
  N += 1
  print(N/2)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
if N%2 == 0:
  print(N/2)
else:
  print(N+1 / 2)

Submission status: Wrong Answer

Solution code:
N = int(input())

if N%2 == 0:
  print(N/2)
else:
  print(N/2 + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
list = [int(x)for x in input().split()]
a_count=0
b_count=0

for i in range(n//2):
  a = max(list)
  list.remove(a)
  a_count += a
  b = max(list)
  list.remove(b)
  b_count += b
print(a_count - b_count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
data = input().split()
N = int(data[0])
Ai = input().split()
ai =[]
for i in range(N):
    ai.append(Ai[i])

ai.sort()#昇順並び替え。list.sort()
alice_total = 0
bob_total = 0
for i in range(1,N+1):
    if i%2 != 0:
        alice_total += int(ai.pop())#list.pop()は配列の末尾の要素を削除して、削除した要素を返すメソッド
    else:
        bob_total += int(ai.pop())
print(alice_total - bob_total)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
A=0
B=0
while len(a) >1:
    A += a.pop(0)
    if len(a)==0:
        break
    B += a.pop(0)
print(A-B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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(x-y)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

cards = sorted(a)
alice = cards[-1::-2]
bob = cards[-2::-2]

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = input()
a = sorted(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()))
a.sort()
cnt = 0
sum1 = 0
sum2 = 0
for i in range(n):
	if cnt % 2 == 0:
		sum1 += a[i]
	else:
		sum2 += a[i]
print(sum1 - sum2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#カードの総数
N = int(input())
#それぞれのカードのリスト
a = list(map(int, input().split()))
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
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

num_list = sorted([ 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_sum-b_sum)

Submission status: Wrong Answer

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_sum - b_sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=sorted(map(int,list(open(0))[1].split()));print(a[::-2],a[1::-2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

al = 0
bo = 0
print(tmp)
for i in range(len(tmp)):
  if i %2 == 0:
    al = al + int(tmp[i])

  else:
    bo = bo + int(tmp[i])

print(al - bo)

Submission status: Wrong Answer

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

tmp = sorted(a, reverse=True)

al = 0
bo = 0

for i in range(len(tmp)):
  if i %2 == 0:
    al = al + int(tmp[i])

  else:
    bo = bo + int(tmp[i])

print(al - bo)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
sortA = sorted(a, reverse=True)
Alice = 0
Bob = 0
print(sortA)
for i in range(len(a)):
    if i % 2 == 0:
        Alice+=sortA[i]
    else:
        Bob+=sortA[i]
    
print(Alice - Bob)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

A_sorted = sorted(A, reverse=True)
print(A_sorted)

Alice_point = 0; Bob_point = 0

for i in range(N):
    
    if i % 2 == 0:
        print("Alice=",i)
        Alice_point += A_sorted[i]
    else:
        print("Bob=",i)
        Bob_point += A_sorted[i]
    
ans = Alice_point - Bob_point

print(ans)