Problem:


Score : 200 points

Problem Statement

Snuke has N sticks.
The length of the i-th stick is l_i.

Snuke is making a snake toy by joining K of the sticks together.

The length of the toy is represented by the sum of the individual sticks that compose it.
Find the maximum possible length of the toy.

Constraints

1 \leq K \leq N \leq 50

1 \leq l_i \leq 50

l_i is an integer.

Input

Input is given from Standard Input in the following format:

N K
l_1 l_2 l_3 ... l_{N}

Output

Print the answer.

Sample Input 1

5 3
1 2 3 4 5

Sample Output 1

12

You can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.

Sample Input 2

15 14
50 26 27 21 41 7 42 35 7 5 5 36 39 1 45

Sample Output 2

386



Sample input:
5 3
1 2 3 4 5


Sample output:
12

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B = map(int,input().split())
L =list(map(int,input().split()))
L = sorted(L ,reverse=True)
a = 0
for i in range(B):
  a = a + L[i]
print(a)

Submission status: Accepted

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

l.sort(reverse = True)
ans = 0

for i in range(K):
    ans += l[i]

print(ans)

Submission status: Accepted

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

print(sum(ll[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse = True)
length = l[:K]
print(sum(length))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
L = list(map(int, input().split()))
L.sort()
print(sum(L[-K:]))

Submission status: Accepted

Solution code:
def main(n: int, k: int, l: list):
    print(sum(sorted(l, reverse=True)[:k]))


if __name__ == "__main__":
    n, k = map(int, input().split())
    l = list(map(int, input().split()))

    main(n, k, l)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
li=list(map(int,input().split()))
li_sort=sorted(li,reverse=True)
print(sum(li_sort[:K]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
a = inpl()
a.sort(reverse=True)
print(sum(a[:k]))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
L =[int(x) for x in input().split()]
L.sort()
result = 0
for i in range(1,K+1):
  result += L[-i]
print(result)

Submission status: Accepted

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

l = sorted(l, reverse=True)

answer = 0
for i in range(k):
    answer += l[i]

print(answer)

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]
LL = sorted(L, reverse=True)
LL_max = sum([LL[i] for i in range(0, K)])
print(LL_max)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
L = list(map(int, input().split()))
new_list = sorted(L, reverse=True)
ans = 0
for i in range(k):
    ans += new_list[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

n, k = [int(x) for x in input().split()]
l = [int(l) for l in input().split()]
l.sort(reverse=1)
print(sum(l[:k]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True);ans=0
for i in range(k):
  ans+=l[i]
print(ans)

Submission status: Accepted

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

l.sort(reverse=True)

print(sum(l[:k]))

Submission status: Accepted

Solution code:
#067b
N,K = map(int, input().split())
l_list = [int(e) for e in input().split()]

l_list.sort(reverse=True)
print(sum(l_list[0:K]))

Submission status: Accepted

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

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

l.sort()

ans = 0
for i in range(n-1, n-k-1, -1):
    ans += l[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n.sort(reverse=True)

x = 0

for i in range(b):
    x += n[i]

print(x)

Submission status: Accepted

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

print(sum(l[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(N, K, inputs):
    rods = string_to_int(inputs[0])
    rods.sort()
    length = 0
    for i in range(K):
        length += rods.pop()
    return length


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    [N, K] = string_to_int(input())
    ret = solve(N, K, inputs(1))
    print(ret)

Submission status: Accepted

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

l_list.sort(reverse=True)

total_length = 0
i = 0
while i < K:
    total_length += l_list[i]
    i += 1

print(total_length)

Submission status: Accepted

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

l.sort(reverse = True)
sum = 0
for i in range(k):
    sum += l[i]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
l=list(map(int, input().split()))
l.sort()
total=0
for i in range(1,k+1):
  total+=l[-i]
print(total)

Submission status: Accepted

Solution code:
#2019/10/25
N, K, *l = map(int, open(0).read().split())
# print(N, K, l)
print(sum(sorted(l)[-K:]))

Submission status: Accepted

Solution code:
a = [list(map(int,input().split())) for l in range(2)]

N=a[0][0]
K=a[0][1]
L=a[1]

list.sort(L, reverse=True)
print(sum(L[0:K]))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
x = list(map(int,input().split()))
x.sort(reverse=True)
print(sum(x[0:K]))

Submission status: Accepted

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

print(sum(sorted(l, reverse=True)[:K]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(lambda x: int(x), input().split())
l=list(map(lambda x: int(x), input().split()))
l.sort(reverse=True)
print(sum(l[:k]))

Submission status: Accepted

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

ans = 0

for i in range(K):
    ans += l[i]
print(ans)

Submission status: Accepted

Solution code:
a,b=input().split()
A = input().split()
B = [int(s) for s in A]
a=int(a)
b=int(b)
for i in range(a-b):

    mi=min(B)
    B.remove(mi)
    B=list(B)
p=sum(B)

print(p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
s = sorted(list(map(int, input().split())), reverse=True)
ans = 0

for i in range(K):
  ans += s[i]
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
L = sorted(map(int, input().split()))
print(sum(L[-k:]))

Submission status: Accepted

Solution code:
# ABC067 B - Snake Toy
N,K = map(int,input().split())
L = list(map(int,input().split()))

L.sort(reverse=True)

ans = 0
for i in range(K):
    ans += L[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
s = list(map(int, input().split()))
s = sorted(s, reverse=True)
print(sum(s[:k]))

Submission status: Accepted

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

l.sort(reverse=True)
L=0
for i in range(K):
     L+=l[i]
print(L)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
list_l = list(map(int, input().split()))
list_l.sort(reverse=True)
print(sum(list_l[:k]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = [int(l) for l in input().split()]

l = sorted(l, reverse=True)
snake = 0
for i in range(len(l)):
    if i >= K:
        break
    snake += l[i]

print(snake)

Submission status: Accepted

Solution code:
#1行目を読み取る
line1 = input()
#スペースで区切る
splitLine1 = line1.split()

#それぞれをintに変換してn, kに代入する
#n, k = map(int, splitLine1)を分解
n = int(splitLine1[0])
k = int(splitLine1[1])

#2行目を読み取る
line2 = input()
#スペースで区切る
splitLine2 = line2.split()

#それぞれをintに変換してリストとして持つ
lengthList = []
for i in range(n):
  eachLengthNum = int(splitLine2[i])
  lengthList.append(eachLengthNum)

#lengthListを数字の小さい順にソートする
lengthList.sort()
#順番に取り出すために、大きい順に並べ替える
#reverseを使うと、listの順番をひっくり返す
lengthList.reverse()

#頭からkまでの数字を合計していく
resultLengthSum = 0
for i in range(k):
  resultLengthSum += lengthList[i]

#答えを出力
print(resultLengthSum)

Submission status: Accepted

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

for i in range(k):
  len += l[i]

print(len)

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    l = list(map(int, input().rstrip('\n').split()))
    l.sort()
    print(sum(l[-k:]))


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse = True)
x = 0
for i in range(k):
  x += l[i]
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(l[N-K:]))

Submission status: Accepted

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

print(sum(l[-1:-K-1:-1]))

Submission status: Accepted

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

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

ans=0

for k in range(K):
  ans=ans+li[k]

print(ans)

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
nums = list(reversed(sorted(list(map(int, input().split())))))
print(sum(nums[:K]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
print(sum(l[0:K]))

Submission status: Accepted

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

print(sum(L[:k]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
L=list(map(int,input().split()))
L=sorted(L)
ans=0
for i in range(k):
  ans+=L.pop()
print(ans)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
A = sorted(map(int, input().split()))
A.sort(reverse=True)
print(sum(A[0:b]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
I = sorted(map(int, input().split()))
print(sum(I[-K:]))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
L = sorted(map(int,input().split()))
print(sum(L[-K:]))

Submission status: Accepted

Solution code:
class PriorityQueue:
    def __init__(self,priority):
        self.__queue=[]
        self.__priority=priority
    def __getvalue(self,i):
        return self.__queue[i-1]
    def __changevalue(self,node1,value1):
        self.__queue[node1-1]=value1
    def __swapvalue(self,node1,node2):
        t=self.__getvalue(node1)
        self.__changevalue(node1,self.__getvalue(node2))
        self.__changevalue(node2,t)
    def __cmp(self,node1,node2):
        return self.__priority(self.__getvalue(node1),self.__getvalue(node2))
    def __update_down(self,node):
        l=node<<1
        r=(node<<1)+1
        largest=node
        if l<=self.getlen() and self.__cmp(l,node)==True:
            largest=l
        if r<=self.getlen() and self.__cmp(r,largest)==True:
            largest=r
        if largest!=node:
            self.__swapvalue(node,largest)
            self.__update_down(largest)
    def __update_up(self,node):
        father=node>>1
        if father<1:
            return 
        if self.__cmp(node,father):
            self.__swapvalue(node,father)
            self.__update_up(father)
    #def show(self):
    #    print(self.__queue)
    def getlen(self):
        return len(self.__queue)
    def empty(self):
        if self.getlen()==0:
            return True
        else:
            return False
    def top(self):
        return self.__queue[0]
    def push(self,value):
        self.__queue.append(value)
        self.__update_up(self.getlen())
    def pop(self):
        self.__swapvalue(1,self.getlen())
        self.__queue.pop()
        self.__update_down(1)

class compare:
    greater=lambda x,y: x>y
    less=lambda x,y: x<y

n,k=input("").split()
n,k=int(n),int(k)
l=input("").split()
l=list(map(int,l))
pq=PriorityQueue(compare.greater)
for i in l:
    pq.push(i)
sum=0
while k>0:
    sum=sum+pq.top()
    pq.pop()
    k=k-1
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
L=[int(x) for x in input().split()]
L.sort(reverse=True)
print(sum(L[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
L=sorted(list(map(int,input().split())))[::-1]
n=0
for i in L[0:M]:
  n+=i
print(n)

Submission status: Accepted

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

print(sum(a[-k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
L=sorted(list(map(int,input().split())),reverse=True)
#print(L)
print(sum(L[:K]))

Submission status: Accepted

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

l=sorted(l,reverse=True)

print(sum(l[0:k]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
print(sum(sorted(map(int, input().split()), key = lambda x:-x)[0:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0

for i in range(k):
    ans += l[i]

print(ans)

Submission status: Accepted

Solution code:
def main():
    n,k=map(int,input().split(' '))
    l=sorted(list(map(int,input().split((' ')))),reverse=True)
    print(sum(l[:k]))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
N,K=map(int,input().split())
l=list(map(int,input().split()))
ls=sorted(l)

print(sum(ls[N-K:]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = [int(i) for i in input().split()]
l.sort(reverse=True)
print(sum(l[0:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l_list = map(int, input().split())
l_list = sorted(l_list, reverse=True)
print(sum(l_list[0:k]))

Submission status: Accepted

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

print(sum(l[:K]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
print(sum(l[0:K]))

Submission status: Accepted

Solution code:
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
L = sorted([int(_) for _ in stdin.readline().rstrip().split()], reverse=True)
print(sum(L[:K]))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
l = [int(_) for _ in input().split()]
l.sort(reverse=True)
print(sum(l[:k]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=True)
L = L[:K]
ans = sum(L)
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
l = [int(i) for i in input().split()]
l.sort()
print(sum(l[-k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
l = sorted(map(int,input().split()),reverse = True)
print(sum([i for i in l[0:K]]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
L=sorted(map(int,input().split()),reverse=True)
print(sum(L[:K]))

Submission status: Accepted

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

ls = sorted(ls, reverse=True)
print(sum(ls[:K]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
L = [int(x) for x in input().split()]
L.sort(reverse=True)
print(sum(L[:K]))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=list(map(int,input().split()))
s.sort()
k=0
for i in range(1,b+1):
    k+=s[-i]
    #print(s[-i])
print(k)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse = True)
max = 0
for i in range(K):
    max += l[i]
print(max)

Submission status: Accepted

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

Submission status: Accepted

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

sum = 0

for i in range(k):
    sum += bows.pop(bows.index(max(bows)))

print(sum)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = [int(i) for i in input().split()]
l = sorted(l)
lsum = sum(l)
ksum = 0
for i in range(n-k):
  ksum = ksum + l[i]
print(lsum - ksum)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
li = list(map(int,input().split()))
li.sort(reverse = True)
print(sum(li[:k]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
li = list(map(int, input().split()))
li = sorted(li, reverse=True)
maxtotal = 0
for i in range(k):
    maxtotal += li[i]
print(maxtotal)

Submission status: Accepted

Solution code:
import numpy as np
import sys
n,k = map(int,input().split())
l = sorted(list(map(int,input().split())))[::-1]
print(sum(l[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k =map(int, input().split())
l =list(map(int, input().split()))
ans =0

l.sort(reverse=True)
for i in range(k):
    ans += l[i]
print(ans)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
l = [int(i) for i in input().split()]
l.sort(reverse = True)
ans =0
for j in range(k):
  ans += l[j]
print(ans)

Submission status: Accepted

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

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

a.sort(reverse=True)

print(sum(a[:k]))

Submission status: Accepted

Solution code:
def resolve():
    n, k = map(int, input().split())
    l = list(map(int, input().split()))
    l.sort(reverse=True)
    print(sum(l[:k]))


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

list.sort(l_list, reverse = True)
print(sum(l_list[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

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

l.sort()

ans=0
for i in range(k):
    ans+=l[n-1-i]
print(ans)

Submission status: Accepted

Solution code:
#coding:utf-8

n, k = map(int, input().split())
l = list(map(int, input().split()))

l_sort = sorted(l, reverse=True)

print(sum(l_sort[:k]))

Submission status: Accepted

Solution code:
N, K = (int(x) for x in input().split())
l = sorted([int(x) for x in input().split()], reverse=True)
print(sum(l[i] for i in range(K)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
L = list(map(int, input().split()))
sorted_L = sorted(L, reverse=True)
print(sum(sorted_L[:K]))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
l = list(map(int,input().split()))
ans = 0
for i in range(k):
    ans += max(l)
    l.remove(max(l))
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
array = list(map(int, input().split()))
array = sorted(array, reverse=True)
ans = 0
for i in range(k):
    ans += array[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(sorted(l, reverse=True)[:k]))

Submission status: Accepted

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

while K > 0:
    a += max(l)
    l.pop(l.index(max(l)))
    K -= 1
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
L = list(map(int, input().split()))
L.sort(reverse=True)
length = 0
for k in range(K):
    length += L[k]
print(length)

Submission status: Accepted

Solution code:
n,k,*l=map(int,open(0).read().split());print(sum(sorted(l)[n-k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
ln = list(map(int, input().split()))
ans = 0
for i in range(K):
  ans += ln.pop(ln.index(max(ln)))
print(ans)

Submission status: Accepted

Solution code:
N,K,*L=map(int,open(0).read().split());print(sum(sorted(L)[-K:]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
l.reverse()
print(sum(l[i] for i in range(k)))

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
print(sum(sorted(list(map(int,input().split())),reverse=True)[0:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

ls = input().split()
ls_arr = np.zeros(N)
for i in range(N):
  ls_arr[i] = int(ls[i])

ls_arr = np.sort(ls_arr)[::-1]

ans = int(ls_arr[:K].sum())

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
*L,    = map(int, input().split())

L.sort()


print(sum(L[-K:]))

Submission status: Accepted

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

l.sort()
l.reverse()

ans = 0
for i in range(k):
    ans += l[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

L = sorted(list(map(int, input().split())))

print(sum(L[N-K:]))

Submission status: Accepted

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

l.sort(reverse=True)
print(sum(l[0:K]))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
l = list(map(int,input().split()))
ans=0

l.sort()
for i in range(k):
    ans+=l[n-i-1]
print(ans)

Submission status: Accepted

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

L.sort(reverse=True)

print(sum(L[:K]))

Submission status: Accepted

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

def main():
    N, K = map(int, input().split())
    l = sorted(list(map(int, input().split())), reverse=True)

    print(sum(l[:K]))



if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

length = 0

for i in range(K):
  length += arr[i]
print(length)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = []

for i in range(K):
    ans.append(l[i])
    
print(sum(ans))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
arr = list(map(int, input().split()))
print(sum(sorted(arr, reverse=True)[0:k]))

Submission status: Accepted

Solution code:
# coding: utf-8
N, K = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
print(sum(l[:K]))

Submission status: Accepted

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

print(sum(l[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = l[:k]
print(sum(ans))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse = True)
sum_l=0
for i in range(0,k):
    sum_l+=l[i]

print(sum_l)

Submission status: Accepted

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

L = sorted(L)[::-1]
print(sum(L[:K]))

Submission status: Accepted

Solution code:
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, k = na()
lll = na()
list.sort(lll, reverse=True)
print(sum(lll[:k]))

Submission status: Accepted

Solution code:
n, k = [int(num) for num in input().split()]
list = [int(num) for num in input().split()]

list.sort(reverse=True)
print(sum(list[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k =  [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
print(sum(l[-k:]))