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: 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 = list(map(int, input().split()))

a.sort(reverse=True)
print(sum(max(a[n:2*n], [a[2*i+1] for i in range(n)])))

Submission status: Accepted

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

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(max(sum(A[N:2*N]),sum(A[1:2*N:2])))

Submission status: Accepted

Solution code:
import itertools
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()
sumnum = 0
for i in range(N*3-1-1, N-1, -2):
    sumnum += a[i]

print(sumnum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))

a = sorted(a, reverse=True)

cnt = 0
ans = 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())
A = list(map(int,input().split()))
A.sort()
ans = 0
for i in range(N):
    ans += A[3*N-(i+1)*2]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
t=int(len(a)-(len(a)/3))
a.sort(reverse=True)
a_cutlist=a[:t+1]
a_cutlist_ans=a_cutlist[1::2]
print(sum(a_cutlist_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*2):
    if i%2 == 1:
        ans += a[i]

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    res = 0
    for i in range(n):
        res += A[-(i + 1) * 2]

    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

mylist.sort(reverse=True)

#print(mylist)

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

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    A = readInts()
    # どうせ大きいやつはとられるしな
    A = sorted(A)
    #print(A)
    ans = 0
    #print(len(A)-1,len(A)-n-1)
    for i in range(len(A)-2,len(A)-2*n-1,-2):
        #print(A[i])
        ans += A[i]
    print(ans)
if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = sorted(map(int, input().split()))
ans = 0
l = 0
r = 3*n-1
while l < r:
    ans += a[r-1]
    l += 1
    r -= 2
    # print(l, r)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

sort_a = sorted(a, reverse=True)

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

print(strong)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
ans = 0
for i in a[1:-n:2]:
    ans += i
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:
n, *a = map(int, open(0).read().split())
print(sum(sorted(a)[-2:n-1:-2]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in 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()
ans = 0
for i in range(1,N+1):
    ans += A[-(2*i)]

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import math

N = int(stdin.readline().rstrip())
a = list(map(int, stdin.readline().rstrip().split()))

a_sorted = sorted(a)
total = 0
for i in range(N*1, N*3, 2):
    total += a_sorted[i]

print(total)

Submission status: Accepted

Solution code:
import sys

n = int(sys.stdin.readline().rstrip())
a = list(map(int, sys.stdin.readline().rstrip().split()))
a.sort()

# print(a)
ans = 0
a = a[n:]
a.reverse()
print(sum(a[1::2]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
sort_A = sorted(A, reverse=True)
sumA = 0
# print(sort_A)
for x in range(N):
    sumA += sort_A[2 * x + 1]
print(sumA)

Submission status: Accepted

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

a.sort()

print(sum(a[n:3*n-1:2]))

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrA = list(map(int,input().split()))

arrA.sort()
A = arrA[N:]
# print(A)
ans = sum(A[::2])

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
sorted_A = sorted(A, reverse=True)

print(sum(sorted_A[1:2*N:2]))

Submission status: Accepted

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

Submission status: Accepted

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

sm=[]
count=0
for i in range(3*N):
    if count==N:
        break
    if i%2==1:
        sm.append(A[i])
        count+=1

ans=sum(sm)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
a.sort(reverse = True)
cnt = n
ind = 0
res = 0
while cnt:
    if ind % 2:
        res += a[ind]
        cnt -= 1
    ind += 1
print(res)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
a.sort(reverse=1)
ans = 0
cnt = 0
i = 1
while cnt < n:
    ans += a[i]
    i += 2
    cnt += 1
print(ans)

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]))

Submission status: Accepted

Solution code:
# AtCoder Group Contest

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

# initialization
a_list = sorted(a_list, reverse=True)
a_max = 0

# sum process
for i in range(2*N): # 2 ~ 2Nまで
    if not i%2==0:
        a_max += a_list[i]

print(a_max)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

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

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

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

print(sum(a[N:][0::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(2*n):
    if i%2 == 1:
        ans += A[i]
print(ans)

Submission status: Accepted

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

a = sorted(a, reverse=True)

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    a.sort(reverse=True)
    print(sum(a[1:2*n:2]))
    return

#Solve
if __name__ == "__main__":
    solve()

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())
li = list(map(int,input().split()))
li.sort()
new_li = li[n:]
#print(new_li)
all_sum = 0
for i,n in enumerate(new_li):
    if i%2 == 0:
        all_sum += n
print(all_sum)

Submission status: Accepted

Solution code:
from collections import deque
N = int(input())
a = list(map(int,input().split()))
pow = 0
a = deque(sorted(a,reverse = True))
for i in range(N):
  a.popleft()
  pow += a.popleft()
  a.pop()
print(pow)

Submission status: Accepted

Solution code:

def myAnswer(N:int,A:list) -> int:
   ans = 0
   A.sort(reverse= True)
   for i in range(1,N*2,2):
      ans += A[i]
   return ans


def modelAnswer():
   tmp=1
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()

Submission status: Accepted

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

ans = sum(a[1:2*n+1:2])
print(ans)

Submission status: Accepted

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

a = sorted(a)[::-1]
b = a[1::2]

result = 0

for i in range(N):
    result += b[i]

print(result)

Submission status: Accepted

Solution code:
N = int(input())
INT_LIST_SORETED = sorted([int(s) for s in input().split()], reverse=True)
SECOND_INT_LIST_MAX = [val for idx, val in enumerate(INT_LIST_SORETED)
                       if idx <= 2 * N and idx % 2 == 1]
print(sum(SECOND_INT_LIST_MAX))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = sorted([int(i) for i in input().rstrip().split(' ')])
print(sum(a[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()
ans = 0
count = 0
for i in range(3*n-2,0,-2):
    ans += a[i]
    count += 1
    if count == n:
        print(ans)
        exit()

Submission status: Accepted

Solution code:
N=int(input())
a=sorted(map(int,input().split()))
ans=0
left=0;right=3*N-1
for i in range(N):
    mid=right-1
    ans+=a[mid]
    right=mid-1
    left+=1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[0]*(3*n)
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
ans=0
#print(a)
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)
s = 0

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

print(s)

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[3*n-2-i*2]
 #print(a[3*n-2-i*3])
print(ans)

Submission status: Accepted

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

a = sorted(a)
a = a[n:]

print(sum(a[0::2]))

Submission status: Accepted

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

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

Submission status: Accepted

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

a.sort(reverse=True)

ans = sum(a[1:2*n+1:2])
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    A.sort(reverse=True)
    sum_a=0
    for i in range(n):
        sum_a+=A[2*i+1]
    print(sum_a)

if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

a.sort()
ans=0
for i in a[n::2]:
    ans+=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
tms=int(input())
strlist=sorted(list(map(int,input().split())))
ans=sum(strlist[tms::][::2])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
A.sort(reverse=True)

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int, input().split()))
A=sorted(A, reverse=True)
ans=sum(A[1::2][:N])
print(ans)
#print(A)
#print(A[1::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(N):
    print
    ans += a[i * 2 + 1]
print(ans)

Submission status: Accepted

Solution code:
tms=int(input())

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

strong_list.sort()

ans=sum(strong_list[tms::][::2])
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=sorted(list(map(int,input().split())))
    i=0
    cnt=0
    while True:
        try:
            cnt+=A[N+2*i]
            i+=1
        except:
            break
    print(cnt)




resolve()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    A.sort()
    print(sum(A[-2:-2*N-1:-2]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort(reverse = True)
    ans = 0
    for i in range(N):
        ans += A[2 * i + 1]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
n = int(input())
List = sorted(list(map(int,input().split())))[::-1]
print(sum([List[2*x+1] for x in range(n)]))

Submission status: Accepted

Solution code:
import sys

INF = 1001001001

def resolve():
  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)

  return

if __name__ == "__main__":
  resolve()

Submission status: Accepted

Solution code:
N=int(input())
*A,=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()

B = A[N::][::2]
print(sum(B))

Submission status: Accepted

Solution code:


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    a= list(map(int,input().split()))
    a = sorted(a,reverse=True)
    res = sum(a[1:2*n:2])
    print(res)
if __name__=='__main__':
    solve()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
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()))
a.sort(reverse=True)
A = a[1:len(a):2]
ans = 0
for i in range(N):
    ans += A[i]
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(2*n):
    if i%2 == 1:
        ans += A[i]
print(ans)

Submission status: Accepted

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

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 = sorted(a)[::-1]
cnt = 0
res = 0
for i in range(1, n * 3 + 1, 2):
    cnt += 1
    res += a[i]
    if cnt >= n:
        break
print(res)

Submission status: Accepted

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

A.sort(reverse=True)
ans = 0
for i, a in enumerate(A[:2 * N]):
    if i % 2 != 0:
        ans += a

print(ans)

Submission status: Accepted

Solution code:
import sys
 
N = int(sys.stdin.readline())
a = sorted(list(map(int, sys.stdin.readline().split(" "))), 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 = list(map(int,input().split()))
a.sort(reverse = True)
ans = 0
for i in range(1,n+1):
    ans += a[i*2-1]
print(ans)

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = sorted(iil(),reverse=True)[1::2]
print(sum(A[:n]))

Submission status: Accepted

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

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import groupby, accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()
a.sort()
b = a[N:][::2]
print(sum(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


N = ii()
A = smii()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a)
ans,nokori=0,0
c=sorted(c.items(),reverse=True)
for k,v in c:
  cnt=min((v+nokori)//2,n)
  n-=cnt
  ans+=int(k)*cnt
  nokori=(v+nokori)%2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
l = len(a)
a.sort(reverse=True)
ans = 0
cnt = 0
for i in range(1,l,2):
  ans += a[i]
  cnt += 1
  if cnt == N: break
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = sorted(list(map(int, input().split())))
ans = []

for i in range(1, N + 1):
  ans.append(a[i * (-2)])

print(sum(ans))

Submission status: Accepted

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

a.sort(reverse=True)

second = 0
for i in range(2*n):
    if i%2 != 0:
        second += a[i]
print(second)

Submission status: Accepted

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

a.sort(reverse=True)

second = []
for i in range(2*n):
    if i%2 != 0:
        second.append(a[i])
print(sum(second))

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[len(a)-2-i*2]
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline

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

A.sort(reverse=True)

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
#2
#入力
N=int(input())
A=list(map(int,input().split()))

#処理
A.sort()
A.reverse()
X=0
for i in range(N):
    X+=A[2*i+1]
    
print(X)

Submission status: Accepted

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