Problem:


Score : 300 points

Problem Statement

There are 3N participants in AtCoder Group Contest.
The strength of the i-th participant is represented by an integer a_i.
They will form N teams, each consisting of three participants.
No participant may belong to multiple teams.

The strength of a team is defined as the second largest strength among its members.
For example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.

Find the maximum possible sum of the strengths of N teams.

Constraints

1 ≤ N ≤ 10^5

1 ≤ a_i ≤ 10^{9}

a_i are integers.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_{3N}

Output

Print the answer.

Sample Input 1

2
5 2 8 5 1 5

Sample Output 1

10

The following is one formation of teams that maximizes the sum of the strengths of teams:

Team 1: consists of the first, fourth and fifth participants.

Team 2: consists of the second, third and sixth participants.

Sample Input 2

10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

Sample Output 2

10000000000

The sum of the strengths can be quite large.



Sample input:
2
5 2 8 5 1 5


Sample output:
10

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(sorted(list(map(int, input().split()))))
group = []
ret = 0
while len(A) > 0:
    group.append([A.pop(0), A.pop(), A.pop()])
for g in group:
    ret += list(sorted(g))[1]
print(ret)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
a.sort(reverse=True)
for _ in range(n):
    a.pop(0)
    ans+=a.pop(0)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = int(0)
#一番チームで最弱のやつを取り出す
for i in range(n):
   ans = sum(a[n:3*n:2])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input()) * 3

arr = list(map(int, input().split(" ")))
arr.sort()

# print(arr)
total = 0
while arr != []:
  arr.pop(0)
  arr.pop(-1)
  total += arr.pop(-1)

print(total)

Submission status: Time Limit Exceeded

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)


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

A.sort(reverse=True)

ans = 0

for _ in range(N):
    A.pop(0)
    A.pop()

    ans += A[0]
    A.pop(0)
    
print(ans)

Submission status: Time Limit Exceeded

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

A.sort(reverse=True)

ans = 0

for _ in range(N):
    A.pop(0)
    A.pop()

    ans += A[0]
    A.pop(0)
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    tot = 0
    while A:
        A.pop()
        tot += A.pop()
        A.pop(0)
    return tot
 
if __name__ == '__main__':
    print(main())

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    tot = 0
    while A:
        A.pop()
        tot += A.pop()
        A.pop(0)
    return tot

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

Submission status: Time Limit Exceeded

Solution code:
member = int(input())
member_array = sorted(list(map(int, input().split())),reverse=True)
result = 0

for i in range(member):
    member_array.pop()
    member_array.pop(0)
    result += member_array.pop(0)

print(result)

Submission status: Time Limit Exceeded

Solution code:
member = int(input())
member_array = sorted(list(map(int,input().split())))
result = 0

for i in range(member):
    for x in range(3):
        if x == 2:
            member_array.pop(0)
        else:
            power = member_array.pop()

    result += power
print(result)

Submission status: Time Limit Exceeded

Solution code:
N = input()
N =int(N)
nums= list(map(int,input().split(" ")))
nums.sort()
ans = 0

for _ in  range(N):
    nums.pop(-1)
    ans += nums.pop(-1)
    nums.pop(0)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

sorted_a = sorted(a)

aa = []
for i in range(n):
    sorted_a.pop(-1)
    sorted_a.pop(0)
    aa.append(sorted_a.pop(-1))

print(sum(aa))

Submission status: Time Limit Exceeded

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

for i in range(N):
    ans += a[-2]
    a = a[1:-2]
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(N):
    if a != []:
        ans += a[-2]
        a = a[1:-2]
print(ans)

Submission status: Time Limit Exceeded

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

while a != []:
    ans += a[-2]
    a = a[1:-2]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
ans = 0
teams = []
for i in range(N):
    teams.append([l[0],l[1],l[-1]])
    l.remove(l[0])
    l.remove(l[1])
    l.remove(l[-1])

print(sum([i[1] for i in teams]))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
power = 0
for i in range(len(l)//3):
    power += l[-2]
    l = l[1:-2]
print(power)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
idx = 0
for i in range(N - 1):
    a.insert(2+idx, a.pop())
    idx += 3
print(sum(a[1::3]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans  = 0
for i in range(N):
    A.pop(-1)
    ans += A.pop(-1)
    A.pop(0)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = list(map(int,input().split()))
L = sorted(L,reverse=True)
ans = 0
while len(L) > 0 :
    L.pop(0)
    ans += L[0]
    L.pop(0)
    L.pop(-1)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
ans=0
for i in range(n):
  del a[0]
  ans+=a[0]
  del a[0]
print(ans)

Submission status: Time Limit Exceeded

Solution code:

def main():
    N = int(input())
    a_list = get_a_list()

    a_list.sort(reverse=True)

    sum_second_a = 0
    
    while len(a_list) > 0:
        a_list.pop(0)
        sum_second_a += a_list.pop(0)
        a_list.pop(-1)

    print(sum_second_a)

def get_a_list():
    a_list = []
    strs = input().split()

    for a in strs:
        a_list.append(int(a))

    return a_list


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def main():
    def _create_trio(_list):
        ret = []
        _list.pop()
        _list.pop(0)
        return _list.pop()

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

    if n <= 0 or n > 10 ** 5:
        return
    for i in a:
        if i <= 0 or i > 10 ** 9:
            return

    a.sort()
    trio_sum = 0

    for i in range(n):
        trio_sum += _create_trio(a)

    return trio_sum

print main()

Submission status: Time Limit Exceeded

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

def main():
    def _create_trio(_list):
        ret = []
        ret.append(_list.pop())
        ret.append(_list.pop())
        ret.append(_list.pop(0))
        return ret

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

    a.sort()
    trio_sum = 0

    for i in range(n):
        trio_sum += _create_trio(a)[1]
    
    return trio_sum

print main()

Submission status: Time Limit Exceeded

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

def main():
    def _create_trio(_list):
        ret = []
        ret.append(_list.pop())
        ret.append(_list.pop())
        ret.append(_list.pop(0))
        return ret

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

    if n <= 0 or n > 10 ** 5:
        return
    for i in a:
        if i <= 0 or i > 10 ** 9:
            return

    a.sort()
    trio_sum = 0

    for i in range(n):
        trio_sum += _create_trio(a)[1]

    return trio_sum

print main()

Submission status: Time Limit Exceeded

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

_sum = 0

for i in range(N):
    a.remove(max(a))
    _sum += max(a)
    a.remove(max(a))

print(_sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    numbers=[]
    dp=[]
    n = int(input())
    numbers=np.array(list(map(int,input().split())),dtype=int)
    numbers.sort()
    print(numbers[n::2].sum())

if __name__=="__main__":
    main()

Submission status: Accepted

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

ans = 0
for i in range(n):
    ans += a[3*n-2-i*2]

print(ans)

Submission status: Accepted

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

a.sort()

ans = a[N:]
ans = ans[::2]
print(sum(ans))

Submission status: Accepted

Solution code:
N = int(input())

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

a = sorted(a, reverse=True)



SUM = 0

for i in range(1, N*2, 2):
    
    SUM = SUM + a[i]

print(SUM)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    ans = sum([A[i] for i in range(3*N-2, N-1, -2)])

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
print(sum(a[0+1:N*2+1:2]))

Submission status: Accepted

Solution code:
n = int(input()); a = list(map(int, input().split()))
a.sort(); x = 0
for i in range(n, 3*n-1, 2): x += a[i]
print(x)

Submission status: Accepted

Solution code:
from collections import deque

def main():
    N = int(input())
    a = list(map(int, input().split()))
    a.sort()
    a = deque(a)
    ans = 0
    for i in range(N):
        a.pop()
        ans += a.pop()
        a.popleft()
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

A_sorted = sorted(A, reverse = True)

strength = 0

for i in range(N):
    strength += A_sorted[2*i+1]

print(strength)

Submission status: Accepted

Solution code:
N,*a = map(int,open(0).read().split())

a = sorted(a)
ans = 0
for i in range(N):
  ans += a[-2-2*i]
print(ans)

Submission status: Accepted

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

A.sort(reverse=True)
i = 1
n = 1
cnt = 0
while 2*i <= 2*N:
    cnt += A[n]
    i += 1
    n += 2
    
print(cnt)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 0
for i in range(n):
    ans += a[(3 * n) - (2*i + 2)]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

    a_list = [int(x) for x in input().rstrip().split(" ")]
    a_list.sort()

    print(sum([a for i, a in enumerate(a_list[n:]) if i % 2 == 0]))


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

cnt = 0
a.sort(reverse=True)

for i in range(1, 2*N, 2):
    cnt += a[i]

print(cnt)

Submission status: Accepted

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

a.sort(reverse=True)
ans = 0
for i in range(N):
    ans += a[2*i + 1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input(' '))
A = input().split(' ')
A = [int(A[i]) for i in range(3*N)]
A = sorted(A, reverse=True)
STG = 0
for i in range(2*N):
  if not i%2==0:
    STG += A[i]
print(STG)

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort(reverse=True)
    ans = sum([A[i] for i in range(2 * N) if i % 2 == 1])
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline())
a = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
a.sort(reverse=True)
ans = 0
for i in range(n):
    ans += a[2*i+1]
print(ans)

Submission status: Accepted

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

ans = 0
a.sort(reverse = True)
for i in range(1, 2 * N, 2):
  ans += a[i]

print(ans)

Submission status: Accepted

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

a.sort()
a.reverse()

A=a[1:(2*N):2]

print(sum(A))

Submission status: Accepted

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

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

ans = 0
for i in range(0, 2*N, 2):
    ans += a[i+N]

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
lb=0
ub=3*n-1
ans=0
for i in range(n):
  lb+=1
  ub-=1
  ans+=a[ub]
  ub-=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def agc012a_atCoder_group_contest():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    total = 0
    for i in range(n):
        a.pop()
        total += a.pop()
    print(total)

agc012a_atCoder_group_contest()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


def main():
    N, *A = map(int, open(0).read().split())
    A.sort()
    print(sum(A[-2 : -2 * N - 1 : -2]))


main()

Submission status: Accepted

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

power = 0
for i in range(N):
  power += power_list[2*i+1]

print(power)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    a = list(mi())

    a.sort(reverse=True)

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

    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a.sort()
a.reverse()

ans=0
cnt=0

for i in range(len(a)):
  if i%2==1:
    ans+=a[i]
    cnt+=1

  if cnt==n:
    break

print(ans)

Submission status: Accepted

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

As.sort(reverse=True)

rlt = 0

for i in range(N):
  rlt += As[2*i+1]
  
print(rlt)

Submission status: Accepted

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

print(sum([a[2*i+1] for i in range(n)]))

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort(reverse=True)
s=0
k=n
for i in range(1,3*n,2):
    s+=l[i]
    k-=1
    if(k==0):
        break
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a.sort(reverse=True)
ans = sum(a[1:2 * n:2])
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = sorted([int(x) for x in input().split()], reverse=True)

ans = 0
for i in range(N):
    ans += a[2 * i + 1]

print(ans)

Submission status: Accepted

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

a.sort(reverse = True)
a_center = [a[i] for i in range(2*n) if i%2==1]

print(sum(a_center))

Submission status: Accepted

Solution code:
N = int(input())
a = sorted(list(map(int, input().split())))
a2 = a[N:]
ans = 0
for i in range(0, 2*N, 2):
    ans += a2[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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())
a=list(map(int,input().split()))
a.sort()
print(sum(a[N::2]))

Submission status: Accepted

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

answer = 0
for i in (range(1, N+1)):
  answer += A[i*2 - 1]

print(str(answer))

Submission status: Accepted

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

a.sort()
ans = 0

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

print(ans)

Submission status: Accepted

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

#print(A)
ans = 0
for i in range(1, 2*n+1, 2):
  ans += A[i]
print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(an) for an in input().split()]
a.sort(reverse=True)
print(sum([a[i*2+1] for i in range(n)]))

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int,input().split()))
ans = 0
a = sorted(a)
for i in range(N):
    ans += a[-2 - 2 * i]
print(ans)

Submission status: Accepted

Solution code:
#
# agc012 a
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2
5 2 8 5 1 5"""
        output = """10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000"""
        output = """10000000000"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    for i in range(N):
        a.pop()
        ans += a.pop()
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

a.sort(reverse = True)
list = []

for i, j in enumerate(a):
    if i % 2 == 1:
        list.append(j)

answer = sum(list[0 : n])

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

	a.sort()

	print(sum(a[N: 3 * N: 2]))


  
if __name__ == "__main__":
  	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

start = 0
end = (3 * N) - 1

ans = 0
while True:
    end -= 1
    ans += A[end]
    start += 1
    end -= 1
    if start > end:
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

a.sort()

a_1 = []
for i in range(N,3*N):
  a_1.append(a[i])

P = []
for i in range(2*N):
  if i%2 == 0:
    P.append(a_1[i])
    
print(sum(P))

Submission status: Accepted

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

ans=0
for i in range(n):
    ans += l[1+2*i]

print(ans)

Submission status: Accepted

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

lis  =sorted(lis)

t1 = sum(lis[n:2*n])
#print(sum(t1))

nlis = lis[::-1]

t2 = 0
for i in nlis[1:2*n:2]:
    t2 += i


print(max(t1, t2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a_list = [int(e) for e in input().split()]
a_list.sort(reverse=True)
a_list = [0] + a_list 
ans_list= list()

for i in range(1,len(a_list)):
    if i%2 == 0:
        ans_list.append(a_list[i])
        if len(ans_list) == N:
            print(sum(ans_list))
            break

Submission status: Accepted

Solution code:
# AGC 012 A - AtCoder Group Contest
N = int(input())
an = list(map(int,input().split()))

lists = [[] for _ in range(N)]
an.sort(reverse=True)

for k in range(N):
    lists[k].append(an[2*k])
    lists[k].append(an[2*k+1])
                    
for i in range(N):
    lists[i].append(an[2*N-1+i])

sasa = 0
for j in range(N):
    sasa += lists[j][1]
print(sasa)

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()

ans = 0

for i in range(N):
    ans += A[N + 2 * i]

print(ans)

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  A.sort(reverse=True)
  ans = sum(A[1:2*N:2])
  return ans
print(solve())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
# 上位 2/3を取得
aa=a[:2*n]
# 上位から1,2..1,2 と割り振る場合の2位の集合を取得
aaa=aa[1::2]

print(sum(aaa))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
participants = sorted([ int(v) for v in input().split(" ") ], reverse=True)

# 1 2 4 5 5 5 7 8 9 
# 1 2 5 5 5 8

sum = 0
for i in range(0, N):
  #print(participants)
  #c_max = participants.pop(0)
  #n_max = participants.pop(0)
  #c_min = participants.pop(-1)
  sum += participants[2*i+1]

print(sum)

Submission status: Accepted

Solution code:
import heapq
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    n = int(input())
    A = [-int(i) for i in input().strip().split()]
    heapq.heapify(A)
    ans = 0
    for i in range(2 * n):
        a = heapq.heappop(A)
        if i % 2 == 1:
            ans -= a

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    c += a[1 + i*2]
print(c)

Submission status: Accepted

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

A = sorted(A)[::-1]
ans = 0

for i in range(1, 2*n, 2):
    ans += A[i]

print(ans)

Submission status: Accepted

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

a=sorted(a)
a=list(reversed(a))
ans=0

for i in range(2*n):
    if i%2==1:
        ans+=a[i]

print(ans)

Submission status: Accepted

Solution code:
n,*aa=map(int, open(0).read().split())

aa.sort(reverse=True)

print(sum(aa[1::2][:n]))

Submission status: Accepted

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

Submission status: Accepted

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