AtCoder Grand Contest 001 - BBQ Easy

Snuke is having a barbeque party.
At the party, he will make N servings of Skewer Meal.
Example of a serving of Skewer Meal
He has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i.
Also, he has an infinite supply of ingredients.
To make a serving of Skewer Meal, he picks 2 skewers and threads ingredients onto those skewers.
Let the length of the shorter skewer be x, then the serving can hold the maximum of x ingredients.
What is the maximum total number of ingredients that his N servings of Skewer Meal can hold, if he uses the skewers optimally?

-----Constraints-----
 - 1≦N≦100
 - 1≦L_i≦100
 - For each i, L_i is an integer.

-----Input-----
The input is given from Standard Input in the following format:
N
L_1 L_2 ... L_{2N}

-----Output-----
Print the maximum total number of ingredients that Snuke's N servings of Skewer Meal can hold.

-----Sample Input-----
2
1 3 1 2

-----Sample Output-----
3

If he makes a serving using the first and third skewers, and another using the second and fourth skewers, each serving will hold 1 and 2 ingredients, for the total of 3.

Source: atcoder | Difficulty: MEDIUM_HARD


Solutions:
N = int(input())
Ls = list(map(int, input().split()))
Ls.sort()
print(sum(Ls[0::2]))


N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(0, 2 * N, 2):
	ans += L[i]
print(ans)


N = int(input())
L = sorted(map(int, input().split()))
ret = 0
for i in range(N):
	ret += L[2 * i]
print(ret)


n = int(input())
ans = int(0)
A = list(map(int, input().split()))
A.sort()
for i in range(n):
	ans += A[i]
all = int(0)
for i in range(n):
	all += A[2 * i]
print(max([ans, all]))


N = int(input())
L = sorted(map(int, input().split()))
print(sum(L[::2]))


n = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(0, n * 2, 2):
	ans += L[i]
print(ans)


n = int(input())
l = sorted(list(map(int, input().split())))
print(sum(l[::2]))


n = input()
l = list(map(int, input().split(' ')))
l.sort()
ans = 0
for i in range(0, len(l), 2):
	ans += l[i]
print(ans)


N = int(input())
L = sorted(list(map(int, input().split())))
print(sum((i for i in L[::2])))


input()
L = [int(l) for l in input().split()]
L.sort(reverse=True)
print(sum(L[1::2]))


n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(0, 2 * n, 2):
	ans += a[i]
print(ans)


n = int(input())
l = list(map(int, input().split()))
l.sort()
print(sum(l[::2]))


N = input()
print(sum(sorted(list(map(int, input().split())))[::2]))


N = int(input())
print(sum((l for l in sorted(list(map(int, input().split())), reverse=True)[1::2])))


li = []
N = int(input())
li = list(map(int, input().split()))
li.sort(reverse=True)
re = sum(li[1::2])
print(re)


n = int(input())
k = list(map(int, input().split()))
k.sort()
print(sum(k[::2]))


N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for x in L[::2]:
	ans += x
print(ans)


N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = sum(L[0:2 * N:2])
print(ans)


n = int(input())
ls = sorted(list(map(int, input().split())))
print(sum(ls[::2]))


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


n = int(input())
l = sorted(list(map(int, input().split())))
c = 0
for i in range(n):
	c += l[2 * i]
print(c)


k = int(input())
li = list(map(int, input().split()))
li.sort()
sum = 0
for k in range(len(li)):
	if k % 2 == 0:
		sum = sum + li[k]
print(sum)


N = input().split()
L_i = list(map(int, input().split()))
L_i.sort(reverse=False)
print(sum(L_i[0::2]))


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


N = int(input())
L = [int(x) for x in input().split()]
L.sort(reverse=True)
print(sum(L[1::2]))


a = int(input())
b = list(map(int, input().split()))
b.sort()
su = 0
for i in range(a):
	su += b[2 * i]
print(su)


N = int(input())
li = list(map(int, input().split()))
li.sort()
P = 0
for i in range(N):
	P += li[i * 2]
print(P)


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


(_, a) = open(0)
print(sum(sorted(map(int, a.split()))[::2]))


N = int(input())
A = sorted(map(int, input().split()))
ans = sum((A[i * 2] for i in range(N)))
print(ans)


input()
a = list(map(int, input().split()))
a.sort()
ans = sum([min(a[2 * i:2 * i + 2]) for i in range(len(a) // 2)])
print(ans)


def main():
	n = int(input())
	l = list(sorted(map(int, input().split())))
	ans = 0
	for i in range(0, 2 * n, 2):
		ans += l[i]
	print(ans)
main()


_ = input()
print(sum(sorted(list(map(int, input().split())))[::2]))


N = int(input())
A = [int(x) for x in input().split()]
A.sort()
print(sum([A[i] for i in range(len(A)) if i % 2 == 0]))


n = int(input())
l = [int(s) for s in input().split()]
l.sort()
ans = 0
for i in range(0, n * 2, 2):
	ans += min(l[i], l[i + 1])
print(ans)


n = int(input())
l = [int(s) for s in input().split()]
l.sort()
print(sum((l[2 * i] for i in range(n))))


print(sum(sorted(map(int, open(0).read().split()[1:]))[::2]))


(n, *l) = map(int, open(0).read().split())
print(sum((min(sorted(l)[i * 2:i * 2 + 2]) for i in range(n))))


N = int(input())
L = [int(i) for i in input().split()]
L.sort()
print(sum(L[::2]))


lines = [[int(num) for num in input().split()] for _ in range(2)]
n = lines[0][0]
skewers = sorted(lines[1])
total = 0
for i in range(n):
	total += skewers[2 * i]
print(total)


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
print(sum([a[i] for i in range(0, 2 * n, 2)]))


N = int(input())
L = list(map(int, input().split()))
print(sum(sorted(L)[0::2]))


(N, *L) = map(int, open(0).read().split())
L = sorted(L)
print(sum(map(min, L[::2], L[1::2])))


N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 0
for i in range(0, len(A), 2):
	ans += min(A[i], A[i + 1])
print(ans)


N = int(input())
list_input = sorted(map(int, input().split()))
print(sum(list_input[::2]))


a = 0
n = int(input())
le = list(map(int, input().split()))
le.sort()
le2 = []
le2 = le[0::2]
print(str(sum(le2)))


n = int(input())
a = sorted(list(map(int, input().split())))
s = 0
for i in range(2 * n):
	if i % 2 == 0:
		s += a[i]
print(s)


n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = sum(l[0::2])
print(ans)


n = int(input())
print(sum(sorted([int(i) for i in input().split()])[-2::-2]))


n = int(input())
L = list(map(int, input().split()))
L.sort()
s = sum(L[::2])
print(s)


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


n = int(input())
num_list = [int(v) for v in input().split()]
print(sum(sorted(num_list)[::2]))


n = int(input())
t = list(map(int, input().split()))
t.sort()
print(sum(t[::2]))


N = int(input())
L = list(map(int, input().split()))
L.sort()
print(sum(L[::2]))


n = int(input())
L = list(map(int, input().split()))
L.sort()
X = L[::2]
print(sum(X))


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


_ = input()
print(sum(sorted([int(i) for i in input().split()])[::2]))


N = int(input())
L = sorted([int(l) for l in input().split()], reverse=True)
print(sum(L[1::2]))


n = int(input())
l = sorted(map(int, input().split()))
ans = 0
while len(l) > 1:
	ans += min(l.pop(), l.pop())
print(ans)


N = int(input())
L = [int(i) for i in input().split()]
L.sort()
print(sum([L[i] for i in range(2 * N) if not i % 2]))


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
s = 0
for i in range(0, 2 * n - 1, 2):
	s += arr[i]
print(s)


import sys
import math
import random
import itertools
import bisect
from copy import copy
from collections import deque, Counter, defaultdict
from decimal import Decimal

def lcm(a, b):
	return a * b // math.gcd(a, b)
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 9
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
	ans += L[i * 2]
print(ans)


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
print(sum(l[::2]))


a = int(input())
b = list(map(int, input().split()))
b = sorted(b)
print(sum(b[0::2]))


n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(2 * n):
	if i % 2 == 0:
		ans += l[i]
print(ans)


n = int(input())
lll = list(map(int, input().split()))
lll.sort()
print(sum(lll[::2]))


n = int(input())
a = list(map(int, input().split()))
a.sort()
print(sum(a[::2]))


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


n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
i = 0
while i < n * 2 - 1:
	ans += l[i]
	i += 2
print(ans)


n = int(input())
l = list(map(int, input().split()))
l.sort()
s = 0
for i in range(2 * n)[::2]:
	s += l[i]
print(s)


import sys
pin = sys.stdin.readline

def main():
	N = int(pin())
	L = list(map(int, pin().split()))
	L.sort()
	ans = 0
	for i in range(0, 2 * N, 2):
		ans += L[i]
	print(ans)
	return

def __starting_point():
	main()
__starting_point()


n = int(input())
l = tuple(sorted(map(int, input().split())))
print(sum(l[::2]))


_ = int(input())
print(sum(sorted([int(x) for x in input().split()])[::2]))


N = int(input())
L = [int(x) for x in input().split()]
L.sort()
answer = sum(L[::2])
print(answer)


n = int(input())
L = sorted(list(map(int, input().split())))
print(sum(L[::2]))


import sys
N = input()
L = list(map(int, input().split()))
L.sort(reverse=True)
a = L[1::2]
s = 0
for x in a:
	s += x
print(s)


N = int(input())
L = list(map(int, input().split()))
L.sort()
l = [L[i * 2] for i in range(N)]
print(sum(l))


n = int(input())
li = list(map(int, input().split()))
li.sort()
print(sum(li[::2]))


import bisect
import heapq
import itertools
import sys
import math
import random
import time
from collections import Counter, deque, defaultdict
from functools import reduce
from operator import xor
from types import FunctionType
from typing import List
mod = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 9)

def lmi():
	return list(map(int, input().split()))

def main():
	N = int(input())
	L = lmi()
	L.sort()
	ans = sum(L[::2])
	print(ans)

def __starting_point():
	main()
__starting_point()


n = int(input())
l = sorted([int(i) for i in input().split()])
ans = 0
for i in range(0, 2 * n, 2):
	ans += l[i]
print(ans)


N = int(input())
L = map(int, input().split())
L = sorted(L)
Total = 0
for i in range(N * 2):
	if i % 2 == 0:
		Total += L[i]
print(Total)


(N, *L) = map(int, open(0).read().split())
L.sort()
print(sum((min(a, b) for (a, b) in zip(L[::2], L[1::2]))))


N = int(input())
L = sorted(map(int, input().split()))
print(sum((min(a, b) for (a, b) in zip(L[::2], L[1::2]))))


n = input()
print(sum(sorted(map(int, input().split()))[::2]))


n = int(input())
lst = list(map(int, input().split()))
i = 0
for j in range(n):
	i += sorted(lst)[2 * j]
print(i)


n = int(input())
l = list(map(int, input().split()))
l.sort()
print(sum([l[i] for i in range(2 * n) if i % 2 == 0]))


n = int(input())
l = sorted(list(map(int, input().split())))
a = 0
for i in range(0, len(l), 2):
	a += l[i]
print(a)


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
print(sum([l[2 * i] for i in range(n)]))


n = int(input())
a = list(map(int, input().split()))
a.sort()
print(sum(map(min, zip(a[::2], a[1::2]))))


n = int(input())
l = sorted([int(x) for x in input().split(' ')])
l.reverse()
s = 0
for i in range(0, n, 1):
	s += min(l[2 * i:2 * i + 2])
print(s)


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	res = sum((arr[i] for i in range(0, len(arr), 2)))
	print(res)
solve()


n = int(input())
ll = sorted(list(map(int, input().split())))
print(sum(ll[::2]))


import sys
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()
YesNo = lambda b: bool([print('Yes')] if b else print('No'))
YESNO = lambda b: bool([print('YES')] if b else print('NO'))
int1 = lambda x: int(x) - 1
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=1)
ans = 0
for i in range(N):
	ans += min(L[i * 2], L[i * 2 + 1])
print(ans)


n = int(input())
n *= 2
lst = input().split(' ')
for m in range(0, n):
	lst[m] = eval(lst[m])
for i in range(0, n):
	for j in range(0, n - i - 1):
		if lst[j] < lst[j + 1]:
			temp = lst[j]
			lst[j] = lst[j + 1]
			lst[j + 1] = temp
result = 0
for k in range(0, n):
	if k % 2 == 1:
		result += lst[k]
print(result)


n = int(input())
l = list(map(int, input().split()))
l.sort()
num = 0
for i in range(0, 2 * n, 2):
	num += min(l[i], l[i + 1])
print(num)


n = int(input())
L = sorted([int(i) for i in input().split()], reverse=True)
print(sum(L[1::2]))


input()
A = list(map(int, input().split()))
A.sort()
r = 0
for i in range(0, len(A), 2):
	r += A[i]
print(r)


n = int(input())
num = [int(i) for i in input().split(' ')]
num.sort(reverse=True)
m = 0
for i in range(1, n + 1):
	m += num[2 * i - 1]
print(m)


N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
ans = 0
for l in L[0::2]:
	ans += l
print(ans)


x = input()
s = sorted(list(map(int, input().split())))
print(sum(s[::2]))


N = int(input())
L = map(int, input().split())

def skewer(input):
	x = sorted(input, reverse=True)
	result = 0
	for i in range(0, len(x)):
		if i % 2 == 1:
			result = result + x[i]
	return result
print(skewer(L))


n = int(input())
array = list(map(int, input().split()))
array.sort()
ans = 0
for i in range(n * 2):
	if i % 2 == 0:
		ans += array[i]
print(ans)


N = int(input())
A = list(map(int, input().split()))
A2 = sorted(A, reverse=True)
ans = 0
for n in range(N):
	ans += A2[2 * n + 1]
print(ans)


a = int(input())
b = list(map(int, input().split()))
c = sorted(b, reverse=True)
d = 0
for i in range(a):
	f = 2 * i
	g = 2 * i + 1
	if c[f] == c[g]:
		d += c[g]
	else:
		d += c[g]
print(d)


N = int(input())
data = list(map(int, input().split()))
data.sort()
j = 0
for i in range(0, 2 * N, 2):
	j += data[i]
print(j)


n = int(input())
s = list(map(int, input().split()))
s.sort()
c = 0
for i in range(0, n):
	c += min(s[i * 2], s[i * 2 + 1])
print(c)


n = int(input())
l = [int(_) for _ in input().split()]
l.sort()
m = l[::2]
print(sum(m))


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


N = int(input())
L = [int(s) for s in input().split()]
L.sort()
print(sum(L[::2]))


N = int(input())
List = [int(i) for i in input().split()]
List.sort()
new_list = List[0::2]
print(sum(new_list))


d = input()
print(sum(sorted(list(map(int, input().split())))[::2]))


n = int(input())
array = [int(x) for x in input().split()]
array.sort()
res = 0
for index in range(0, n):
	res += min(array[2 * index], array[2 * index + 1])
print(res)


N = int(input())
M = sorted(list(map(int, input().split())))
if N % 2 == 1:
	M.pop(-1)
print(sum(M[::2]))


n = int(input())
l = list(map(int, input().split()))
l.sort()
l.reverse()
print(sum(l[1::2]))


input()
a = [int(i) for i in input().split()]
a.sort()
print(sum(a[::2]))


N = int(input().strip())
L = list(map(int, input().strip().split()))
L.sort()
amt = 0
while len(L) > 0:
	(L1, L2) = L[0:2]
	amt += min([L1, L2])
	del L[0:2]
print(amt)


N = int(input())
L = list(map(int, input().split()))
L.sort()
S = 0
for i in L[::2]:
	S = S + i
print(S)


list = []
for i in range(2):
	a = input()
	list.append(a)
N = list.pop(0)
s = list.pop(0)
stick_list = s.split()
stick_list.sort(key=int)
stick_list = [int(s) for s in stick_list]
sum = 0
for i in stick_list[::2]:
	sum = sum + i
print(sum)


n = int(input())
a = list(map(int, input().split()))
a.sort()
sum = 0
for i in range(0, len(a), 2):
	sum += a[i]
print(sum)


N = int(input())
X = sorted(list(map(int, input().split())))
s = 0
for i in range(N):
	s += X[2 * i]
print(s)


N = int(input())
L = list(map(int, input().split()))
L.sort()
print(sum((min(a, b) for (a, b) in zip(L[::2], L[1::2]))))


N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
ans = 0
for i in range(1, 2 * N, 2):
	ans += L[i]
print(ans)


N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
print(sum(L[1::2]))


n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=1)
res = 0
for i in range(2 * n):
	if i % 2 != 0:
		continue
	res += min(l[i], l[i + 1])
print(res)


N = int(input())
length = list(map(int, input().split(' ')))
length.sort()
print(sum(length[0::2]))


n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
print(sum(a[1::2]))


N = int(input())
L = [int(i) for i in input().split()]
L.sort(reverse=True)
S = 0
for i in range(N):
	S += L[2 * i + 1]
print(S)


N = int(input())
L = [int(_) for _ in input().split()]
result = sum(sorted(L)[::2])
print(result)


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


n = int(input())
lst = list(map(int, input().split()))
lst.sort()
s = sum(lst[0::2])
print(s)


n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for _ in range(n):
	ans += l[2 * _]
print(ans)


a = int(input())
x = sorted(list(map(int, input().split())))
cnt = 0
for i in range(a):
	cnt += x[2 * i]
print(cnt)


input()
a = list(map(int, input().split()))
a.sort()
ans = 0
while len(a) > 0:
	ans += a[0]
	a = a[2:]
print(ans)


N = int(input())
L = list(map(int, input().split()))
L = sorted(L, reverse=True)
mL = L[1::2]
print(sum(mL))


N = int(input())
A = sorted([int(a) for a in input().split()])
print(sum(A[::2]))


N = int(input())
lst = sorted(map(int, input().split()))
print(sum(lst[::2]))


n = int(input())
print(sum(sorted(list(map(int, input().split())))[0::2]))


n = int(input())
x = sorted(list(map(int, input().split())))
s = 0
for i in range(n):
	s += x[i * 2]
print(s)


n = int(input())
lis = list(map(int, input().split()))
lis.sort()
print(sum(lis[::2]))


import math
from math import gcd, pi, sqrt
INF = float('inf')
MOD = 10 ** 9 + 7
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
import itertools
import bisect
import re
from collections import Counter, deque, defaultdict

def iinput():
	return int(input())

def imap():
	return map(int, input().split())

def ilist():
	return list(imap())

def irow(N):
	return [iinput() for i in range(N)]

def sinput():
	return input().rstrip()

def smap():
	return sinput().split()

def slist():
	return list(smap())

def srow(N):
	return [sinput() for i in range(N)]

def main():
	n = iinput()
	s = sorted(ilist())[::2]
	print(sum(s))

def __starting_point():
	main()
__starting_point()


input()
l = list(map(int, input().split()))
l.sort()
print(sum([v for (i, v) in enumerate(l) if i % 2 == 0]))


N = int(input())
(*L,) = map(int, input().split())
L.sort()
ans = sum((L[2 * i] for i in range(N)))
print(ans)


n = int(input())
L = sorted(map(int, input().split()))
ans = L[0::2]
ans = sum(ans)
print(ans)


(n, l) = open(0)
print(sum(sorted(map(int, l.split()))[::2]))


N = int(input())
alist = list(map(int, input().split()))
alist.sort()
ans = 0
for i in range(N * 2):
	if i % 2 == 0:
		ans += alist[i]
print(ans)


n = int(input())
L = list(map(int, input().split()))
L.sort()
print(sum([L[i] for i in range(0, 2 * n, 2)]))


input()
print(sum(sorted([int(_) for _ in input().split()])[0::2]))


n = int(input())
L = list(map(int, input().split()))
mn = 0
L.sort()
print(sum(L[0::2]))


N = input().rstrip()
Ls = list(map(int, input().split()))
Ls.sort(reverse=True)
totalBarLength = 0
for i in range(0, len(Ls), 2):
	barLength = Ls[i + 1]
	totalBarLength += barLength
print(totalBarLength)


n = int(input())
A = sorted(list(map(int, input().split())))
print(sum(A[::2]))


N = int(input())
A = list(map(int, input().split()))
A.sort()
print(sum((A[2 * i] for i in range(N))))


import sys

def input():
	return sys.stdin.readline().rstrip()
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(0, 2 * N, 2):
	ans += L[i]
print(ans)


N = int(input())
L = list(map(int, input().split()))
L.sort()
L = L[::-1]
r = 0
for i in range(N):
	r += L[1]
	L = L[2:]
print(str(r))


n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
s = 0
for i in range(len(l)):
	if i % 2 == 0:
		s += l[i]
print(s)


import sys
input = sys.stdin.readline

def main():
	N = int(input())
	L = list(map(int, input().split()))
	L.sort()
	ans = sum((L[i] for i in range(0, 2 * N, 2)))
	print(ans)

def __starting_point():
	main()
__starting_point()