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:
def mainB():
    N, K = map(int, input().split())
    l =  list(map(int, input().split()))
    l = sorted(l)[::-1]
    ans = 0
    for i in range(K):
        ans += l[i]
    print(ans)

mainB()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, k =map( int, raw_input().split())
l =map( int, raw_input().split())
L = sorted(l)[::-1]
print '{}'.format(sum(L[:k]))

Submission status: Accepted

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

import re

n, k = map(int, re.split('\s', raw_input()))
l = map(int, re.split('\s', raw_input()))
ans = 0

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

print ans

Submission status: Accepted

Solution code:
arr = raw_input().split(' ')
n = int(arr[0])
k = int(arr[1])
l = raw_input().split(' ')
l = map(int,l)
l.sort()
for i in l:
	i = int(i)
ans = 0
for i in range(n-k, n):
	ans = l[i] + ans
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())
lengths = map(int,input().split())

lengths = sorted(lengths)
result = 0
for i in range(len(lengths)-1,len(lengths)-1-K,-1):
    result += lengths[i]
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Imp = list(map(int, input().split()))
Blist = list(map(int, input().split()))
Blist.sort()

out = 0
for i in range(Imp[1]):
    out += Blist[-(i+1)]
    
print(out)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,k = LI()
    a = sorted(LI(),reverse=True)

    return sum(a[:k])


print(main())

Submission status: Accepted

Solution code:
from sys import stdin
n,k = map(int,stdin.readline().split())
a = map(int,stdin.readline().split())
a.sort()
a.reverse()
print sum(a[:k])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N, K = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse = True)
ans = 0
for tmp in range(K):
    ans += l[tmp]
print(ans)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N, K = list(map(int, input().split()))
    data = list(map(int, input().split()))
    data.sort(reverse = True)
    result = sum(data[:K])
    print(result)

Submission status: Accepted

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

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

l.sort()
l.reverse()

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

Submission status: Accepted

Solution code:
n,m=map(int,raw_input().split())
s=raw_input().split()
a=[]
t=[0 for i in range(n)]
for i in range(n):
    a.append(int(s[i]))
sum=0
a=sorted(a)
for j in range(n-1,n-m-1,-1):
    sum=sum+a[j]
print sum

Submission status: Accepted

Solution code:
import numpy as np

nk = input().split(' ')
n, k = (int(nk[0]), int(nk[1]))
l = [int(num) for num in input().split(' ')]
max = 0
for _ in range(k):
    m = np.array(l).max()
    max += m
    l.remove(m)
print(max)

Submission status: Accepted

Solution code:
#ABC067B

n,k=map(int,raw_input().split())
l=map(int,raw_input().split())
l=sorted(l,reverse=True)
res=0
for i in xrange(k):
 res+=l[i]
print res

Submission status: Accepted

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


a.sort(reverse=True)
ans=sum(a[:K])
print(ans)

Submission status: Accepted

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

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

#ソートする
l.sort()
#逆にする（降順)
l.reverse()
#合計
sum=0;

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

print(sum)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
l=list(map(int,input().split()))
S=0
for i in range(K):
    S+=max(l)
    l.remove(max(l))
print(S)

Submission status: Accepted

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

from collections import defaultdict
from math import factorial as f
from fractions import gcd as g

n, k = [int (i)  for i in raw_input ().split ()]
a = [int (i)  for i in raw_input ().split ()]
a.sort (reverse = True)
print sum (a [:k])

Submission status: Accepted

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

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

sorted_l = sorted(l)[::-1]

print(sum(sorted_l[:K]))

Submission status: Accepted

Solution code:
inpt = map(int, raw_input().split())
n = inpt[0]
k = inpt[1]
lst = map(int, raw_input().split())
lst.sort()
ans = 0
for i in range(0, k):
	ans += lst[-1-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 i in range(K):
	ans += l[i]

print(ans)

Submission status: Accepted

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

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

l.sort()
s = 0
for i in range(K):
    s += l[N-K+i]

print(s)

Submission status: Accepted

Solution code:
def solution(n, k, l_list):
    l_list.sort(reverse=True)
    result = sum(l_list[:k])
    return result


N, K = [int(value) for value in input().split(' ')]
l_list = [int(value) for value in input().split(' ')]
print(solution(N, K, l_list))

Submission status: Accepted

Solution code:
def read(): return list(map(int, input().split()))

n, k = read()
l = read()
print(sum(sorted(l)[::-1][:k]))

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort(reverse = True)
print sum(a[0:k])

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort(reverse = True)
ans = 0
for i in xrange(k):
    ans += a[i]
print ans

Submission status: Accepted

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

len_list.sort(reverse=True)

print(sum(len_list[:k]))

Submission status: Accepted

Solution code:
N_K = map(int, raw_input().split())

l = map(int, raw_input().split())
l.sort()
l.reverse()

ans = 0

for i in range(N_K[1]):
    ans += int(l[i])

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:
import sys

# sys.stdin = open('b1.in')


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


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n, k = read_int_list()
    l = read_int_list()
    l.sort()
    res = sum([i for i in l[-k:]])
    print(res)


main()

Submission status: Accepted

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

l = map(int, raw_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 =list(map(int, input().split()))
# N, K = 15, 14
l = list(map(int, input().split()))
# l = [50, 26, 27, 21, 41, 7, 42, 35, 7, 5, 5, 36, 39, 1, 45]
sorted_l = sorted(l, reverse=True)
print(sum(sorted_l[:K]))

Submission status: Accepted

Solution code:
sticks_canJoinNum = input()
str_stickLength = input()

sticks_num = int(sticks_canJoinNum.split()[0])
num_canJoin = int(sticks_canJoinNum.split()[1])
stick_list = [int(i) for i in str_stickLength.split()]

stick_list.sort(reverse=True)
max_length = sum(stick_list[:num_canJoin])
print(max_length)

Submission status: Accepted

Solution code:
a=input().split()
b=input().split()
N=int(a[0])
K=int(a[1])
c=[]
s=0

for i in range(N):
 l=int(b[i])
 c.append(l)
c.sort(reverse=True)
for i in range(K):
 s +=c[i]
print(s)

Submission status: Accepted

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

l.sort(reverse=True)
for num in range(K):
    res = res + l[num]
print(str(res))

Submission status: Accepted

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

H.sort(reverse=True)

A=H[0:K]
B=sum(A)

print(B)

Submission status: Accepted

Solution code:
ab = input().split(' ')
st = input().split(' ')
st = [int(x) for x in st]
k = int(ab[1])
max1 =0
pl = sum(st)
for i in range(int(ab[0])-k):
    pl -= min(st)
    del st[st.index(min(st))]


        
print(pl)

Submission status: Accepted

Solution code:
A = input().split()

N = int(A[0])
K = int(A[1])

A = input().split()
l = []

for n in range(N):
    l.append(int(A[n]))

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
c = list(map(int,input().split()))
d = 0
for x in range(b):
    cc = max(c)
    d += cc
    c.remove(cc)
print(d)

Submission status: Accepted

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

l.sort()
l.reverse()

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

def main(K):
    ans = 0
    L.sort()
    L.reverse()
    i = 0
    while i < K:
        ans += L[i]
        i += 1
    return ans

print(main(K))

Submission status: Accepted

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

Submission status: Accepted

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

#すぬけくんは N 本の棒を持っています。 i 番目の棒の長さは li です。
#すぬけくんは K 本の棒を選んでつなげて、ヘビのおもちゃを作りたいです。
#ヘビのおもちゃの長さは選んだ棒たちの長さの総和で表されます。 
#ヘビのおもちゃの長さとしてありうる長さのうち、最大値を求めなさい。

A = input().split()
B = input().split()
#A = [5, 3]
#B = [1, 2, 3, 4, 5]
#A = [15, 14]
#B = [50, 26, 27, 21, 41, 7, 42, 35, 7, 5, 5, 36, 39, 1, 45]

N = int(A[0])
K = int(A[1])

C = []

for i in range(N):
    C.append(int(B[i]))

D = sorted(C)

ans = 0

for i in range(K):
    x = N - i -1
    ans = ans + D[x]

print(ans)

Submission status: Accepted

Solution code:
if(__name__ == "__main__"):
    N, K =[int(i) for i in input().split()]
    a = [int(i) for i in input().split()]
    #print(a,b)
    
    maxlist = a[:K]
    #print(maxlist)
    for i in range(K,N):
        if(min(maxlist) < a[i]):
            maxlist.remove(min(maxlist))
            maxlist.append(a[i])
            #print(maxlist)
        
    print(sum(maxlist))

Submission status: Accepted

Solution code:
def main():
    N, K = list(map(int, input().strip().split()))
    ls = list(map(int, input().strip().split()))
    k_total = sum(sorted(ls, reverse=True)[:K])
    print(k_total)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

list.sort()
list.reverse()

sum=0
for i in range(k): sum+=list[i]

print(sum)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
import itertools
import numpy as np

N,K = map(int,input().split())
l = np.array(list(map(int,input().split())))

ans = 0
for i in range(K):
    max_i = np.argmax(l)
    ans += l[max_i]
    l = np.delete(l,max_i)

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int, raw_input().split())
l = map(int, raw_input().split())
l.sort(reverse=True)

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

print a

Submission status: Accepted

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

l.sort(reverse = True)

s = 0
for i in range(K):
    s += int(l[i])

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__=='__main__':
    index_src = input()
    index = index_src.split(' ')
    alls = int(index[0])
    adds = int(index[1])
    numbers_src = input().split(' ')
    numbers_int =[]
    for i in numbers_src:
        numbers_int.append(int(i))
    numbers_int.sort()
    numbers_int.reverse()
    ans = 0
    for i in range(0,adds):
        ans += numbers_int[i]
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python

import sys

def main(argv):
    N, K = map(lambda x: int(x), sys.stdin.readline().split(" ", 2))
    while N and K:
        L = map(lambda x: int(x), raw_input().split(" ", N))
        print(sum(sorted(L)[-K:]))

        line = sys.stdin.readline()
        if line:
            N, K = map(lambda x: int(x), line.split(" ", 2))
        else:
            N = None
            K = None

if __name__ == "__main__":
    main(sys.argv)

Submission status: Accepted

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

N,K=map(int,raw_input().split())
l=map(int,raw_input().split())
l.sort()
print sum(l[len(l)-K:len(l)])

Submission status: Accepted

Solution code:
#Python

l = map(int, raw_input().split())

N=l[0]
K=l[1]
#print N
#print K

a = map(int, raw_input().split())
#print a


a.sort()
a.reverse()

#print a

sum=0
for i in range(K):
	sum+=a[i]

print sum

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nk = [int(x) for x in input().split()]
n = nk[0]
k = nk[1]
bars = [int(y) for y in input().split()]
bars.sort()
bars.reverse()
ans = 0
for i in range(k):
    ans += bars[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(K):
	ans += max(l)
	l.pop(l.index(max(l)))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

N, K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]

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

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    L = tuple(map(int, input().split()))

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

main()

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 = 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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

ls = sorted([x for x in map(int, input().split())])

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

n, k = map(int, raw_input().split())
l = map(int, raw_input().split())

l.sort()
print sum(l[-k:])

Submission status: Accepted

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

    print(sum(L[:K]))

if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

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[-i - 1]

print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
L = input().split()
l = []
for x in L:
 l.append(int(x))
l.sort()
sum = 0
for x in range(1,k+1):
 sum += l[-x]
print(sum)

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[N-K:N]))

Submission status: Accepted

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

print(sum(sorted(l)[-k:]))

Submission status: Accepted

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

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

Submission status: Accepted

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

l.sort()
l = l[::-1]

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

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

Submission status: Accepted

Solution code:
# encoding:utf-8

def main():
	N, K = list(map(int, input().split()))
	len_bar = list(map(int, input().split()))
	len_bar.sort()
	adapt_bar = len_bar[N-K:]
	print(sum(adapt_bar))

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
s = input().split()
s = [int(i) for i in s]
N = s[0]
K = s[1]

s = input().split()
s = [int(i) for i in s]
s = sorted( s )
bubun = s[-K : ]
print(sum(bubun))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
src = list(map(int, input().split()))
src.sort()
print(sum(src[-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:
# Snake Toy

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

Submission status: Accepted

Solution code:
import sys

def main():
    line = sys.stdin.readline()
    lst = line.split()
    n = int(lst[0])
    k = int(lst[1])

    line = sys.stdin.readline()
    lst = line.split()
    l_lst = sorted([int(l) for l in lst], reverse=True)

    print(sum(l_lst[:k]))


    return 0

if __name__ == '__main__':
    sys.exit(main())

Submission status: Accepted

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

print(sum)

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
l = list(map(int, raw_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()
print(sum(L[-K:]))

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 = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
nums = [int(x) for x in input().split()]
N,K = nums[0],nums[1]
L = [int(x) for x in input().split()]
L.sort(reverse=True)
ans = sum(L[:K])
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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



def main():
    n, k = map(int, input().split())
    ls = list(map(int, input().split()))

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

if __name__ == "__main__": main()

Submission status: Accepted

Solution code:
import sys
n, k = map(int, sys.stdin.readline().split())
a = sorted(map(int, sys.stdin.readline().split()))


print sum (a[n - k:])

Submission status: Accepted

Solution code:
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    N, K = get_ln_int_inputs()
    l = get_ln_int_inputs()

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


main()

Submission status: Accepted

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

L.sort()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort(reverse=True)
    print(sum[:K])

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
int main() {
  int N;
  int K;
  int a[55];
  cin >> N >> K;
  
  for(int i=0; i<N; ++i) {
    cin >> a[i];
  }
  sort(a,a+N,greater<int>());
  int ans=0;
  for(int i=0; i<=K; ++i) {
    ans += a[i];
  }
  cout << ans << endl;
}

Submission status: Runtime Error

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

l.sort(reversed=True)
print(sum(l[:k]))

Submission status: Runtime Error

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

l_sum = 0
for k in range(K):
    l = ls[k]
    l_sum += l

print(l_sum)

Submission status: Runtime Error

Solution code:
def solve():
    N, K = map(int, input().split())
    L = [int(i) for i in input().split()]
    L.sort(reversed = True)
    print(sum(L[:K]))


if __name__ == "__main__":
    solve()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

l = sorted(l. reverse = True)

print(sum(l[:K]))

Submission status: Runtime Error

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

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

print(c)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
l = list()
for _ in range(n):
	l.append(int(input()))
	
l.sort(reverse = True)

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

Submission status: Runtime Error

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

l = sorted(l)[::-1]
ans = 0
for i in range(K):
  ans += l[i]

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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

l.sort(reverse=True)

sum = 0

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

print(sum)

Submission status: Runtime Error

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

l.sort()

print(l[-1]+l[len(l)-2]+l[len(l)-3])

Submission status: Runtime Error

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

l.sort()

print(l[-1]+l[-2]+l[-3])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,K=MI()
ls=sorted(LI(),reverse=True)
ans=0
for i in range(k):
    ans+=ls[i]
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

Solution code:
import sys

N, K = map(int, sys.stdin.readline())
L = sorted(list(map(int, sys.stdin.readline().split(" "))), reverse=True)
print(sum(L[0:K]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  int l[k];
  rep(i, n) cin >> l[i];

  sort(l, l+n, greater<int>());
  int sum = 0;
  rep(i, k) sum += l[i];

  cout << sum << endl;

}

Submission status: Runtime Error

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