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: Wrong Answer

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.reverse()
for i in range(0,k):
        ans += l[i]

print ans

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
#ABC067B

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

Submission status: Wrong Answer

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

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

l.reverse()

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

print(sum)

Submission status: Wrong Answer

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(l)
print(sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

l.sort(reverse = True)

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

print(s)

Submission status: Wrong Answer

Solution code:
ab = input().split(' ')
st = input().split(' ')
st = [int(x) for x in st]
k = int(ab[1])
max1 =0
for i in range(int(ab[0])-k+1):
    if sum(st[i:i+k+1] ) > max1:
        max1=  sum(st[i:i+k] )
        
print(max1)

Submission status: Wrong Answer

Solution code:
ab = input().split(' ')
st = input().split(' ')
st = [int(x) for x in st]
k = int(ab[1])
max1 =0
for i in range( int(ab[0])-k):
    if sum(st[i:i+k+1] ) > max1:
        max1=  sum(st[i:i+k] )
        
print(max1)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
c, d = map(int, input().split())
ans = 0

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

for i in range(d) :
    ans = ans + a[c-1-i]

print (ans)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
# coding: utf-8
# Here your code !

x=input()
a=int(x.split(" ")[0])
b=int(x.split(" ")[1])
y=input()
c=y.split(" ")
c=sorted(c,reverse=True)
print (c)
sum = 0
for i in range(b):
    sum += int(c[i])
print (sum)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

l.reverse()

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import permutations,combinations

N, K = map(int, input().split())
L = list(map(int, input().split()))
P = list(combinations(L, K))
maximum = 0
for p in P:
    maximum = max(maximum, sum(p))
print(maximum)

Submission status: Time Limit Exceeded

Solution code:
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  N, K = map(int, input().split())
  L = list(map(int, input().split()))
  ans = 0
  for com in combinations(L,K):
    cnt = 0
    for c in com:
      cnt += c
    ans = max(ans,cnt)
  return ans
print(solve())

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

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

ans = max([sum(combi) for combi in combinations(L, K)])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

ans = 0
for c in itertools.combinations(l, k):
    ans = max(ans, sum(c))

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

max=-3

for i in list(itertools.combinations(l,K)):
    if sum(i)>=max:
        max=sum(i)

print(max)

Submission status: Time Limit Exceeded

Solution code:
import itertools
n, k = (int(i) for i in input().split())
l = list(int(j) for j in input().split())
ans = 0
for i in itertools.combinations(l, k):
    if sum(i) > ans:
        ans = sum(i)
print(ans)

Submission status: Time Limit Exceeded

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

ans=0
for c in combinations(range(N),K):
  ans=max(ans,sum([l[i] for i in c]))
print(ans)

Submission status: Time Limit Exceeded

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

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

l_set = list(itertools.combinations(l,K))

max_s = 0
for i in range(len(l_set)):
    l_sum = sum(l_set[i])
    if l_sum>max_s:
        max_s = l_sum

print(max_s)

Submission status: Time Limit Exceeded

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

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

l_set = list(itertools.combinations(l,K))

max_s = 0
for i in range(len(l_set)):
    if sum(l_set[i])>max_s:
        max_s = sum(l_set[i])

print(max_s)

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

final.sort(reverse = True)
print(sum(final[:b]))

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

Submission status: Accepted

Solution code:
from typing import List


def answer(n: int, k: int, l: List[int]) -> int:
    l.sort(reverse=True)
    return sum(l[:k])


def main():
    n, k = map(int, input().split())
    l = list(map(int, input().split()))
    print(answer(n, k, l))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum_length)

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(reverse=True)
print(sum(l[0:k]))

Submission status: Accepted

Solution code:
# B - Snake Toy
def main():
    _, k = map(int, input().split())
    l = list(map(int, input().split()))
    cnt = 0
    l.sort(reverse=True)

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



if __name__ ==  "__main__":
    main()

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()))
l.sort()
Sum = 0

for i in range(K):
    Sum += l[N - i - 1]

print(Sum)

Submission status: Accepted

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

l = sorted(l, reverse=True)
cn = 0
for i in range(K):
    cn = cn + l[i]
    
print(cn)

Submission status: Accepted

Solution code:
lst = input().split()
N = int(lst[0])
K = int(lst[1])

L = input().split()
for i in range(N):
   L[i] = int(L[i])

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

lst = sorted(lst)
print(sum(lst[(-1) * k:]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = [int(s) for s in input().split()]

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
print(sum(sorted(list(map(int,input().split())))[::-1][: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[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:
import sys
from typing import List

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

bar = sorted(ll)[::-1]
#bar2 = bar[::-1]
ans = sum(bar[0:k])

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N, K = map(int, input().split())
L = sorted(list(map(int, input().split())))
print(sum(L[-K:]))

Submission status: Accepted

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

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())
lst = list(map(int, input().split()))
lst.sort(reverse = True)
ans = 0
for i in range(0, k):
    ans += lst[i]

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = sorted(l)
x = 0
for i in range(-1, -1-k, -1):
    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)
cnt = 0
for i in range(k):
    cnt += l[i]
print(cnt)

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=list(map(int ,input().split()))
l=list(map(int ,input().split()))
ans=0
sorted_l=l.sort()
l.reverse()
for i in range(0,k):
	ans+=l[i]
	
print(ans)

Submission status: Accepted

Solution code:
n, k = (int(x) for x in input().split())
L = [int(x) for x in input().split()]
ans = sum(sorted(L, reverse=True)[:k])
print(ans)

Submission status: Accepted

Solution code:
with open(0) as f:
    N, K, *l = map(int, f.read().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())
A = list(map(int, input().split()))
A.sort(reverse = True)
print(sum(A[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l.sort(reverse=True)
snake = []

for i in range(K):
    snake.append(l[i])

print(sum(snake))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = sorted(map(int,input().split()))
a.reverse()
print(sum(a[: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:
a,b=map(int,input().split())
N = sorted(list(map(int,input().split())))[::-1]
print(sum(N[:b]))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
l = list(sorted(map(int,input().split())))[::-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)

print(sum(L[:K]))

Submission status: Accepted

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

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

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, K = map(int, readline().split())
    l = list(map(int, readline().split()))

    l.sort(reverse=True)

    print(sum(l[:K]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
n,k = map(int, sys.stdin.readline().rstrip("\n").split())
l = [int(s) for s in sys.stdin.readline().rstrip("\n").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:
# -*- coding: utf-8 -*-

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

l_sorted = sorted(l, reverse=True)
total = 0
for i in range(K):
    total += l_sorted[i]

print(total)

Submission status: Accepted

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


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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(sum(L)-s)

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


print(sum(l[:K]))

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8


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


if __name__ == "__main__":
    main()

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())
ls = list(map(int, input().split()))
print(sum(sorted(ls, reverse=True)[:K]))

Submission status: Accepted

Solution code:
# スペース区切りの整数の入力
n, k = map(int, input().split())
# スペース区切りの整数の入力
data =  list(map(int, input().split()))
l = sorted(data, 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)

sum = 0
cnt = 0
while K > cnt:
    sum += l[cnt]
    cnt += 1
print(sum)

Submission status: Accepted

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

abc067b_snake_toy()

Submission status: Accepted

Solution code:
# coding: utf-8

num, choose_num = map(int, input().split())
total = 0
stick_length = input().split(" ")

str_num = [int(n) for n in stick_length]
list.sort(str_num, reverse=True)

for i in range(choose_num):
    total += str_num[i]

print(total)

Submission status: Accepted

Solution code:
N_hon, K_part = map(int, input().split())
length = list(map(int, input().split()))

length.sort()
ans = sum(length[-K_part:])

print(ans)

Submission status: Accepted

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

L=sorted(l)

print(sum(L[(n-k):]))

Submission status: Accepted

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

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

Submission status: Accepted

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


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


main()

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())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans = 0
for i in range(k):
  ans += a[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[0:K]))

Submission status: Accepted

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

print(sum(sorted(num_list, 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[0:k]))

Submission status: Accepted

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

Submission status: Accepted

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

l2=sorted(l, reverse=True)
length = sum(l2[0:k])
print(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:
n, k = map(int, input().split())
s = list(map(int, input().split()))
s.sort()
print(sum(s[n-k:]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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())
a = list(map(int, input().split()))
a.sort(reverse = True)
sum = 0
for i in range(k):
    sum = sum + a[i]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

s = sorted(l)

ans = sum(s[N - K:])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_,k=map(int,input().split());print(sum(sorted(map(int,input().split()))[-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 = map(int, input().split())
l = [int(x) for x in 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:
_,k,*l=map(int,open(0).read().split())
l.sort(reverse=True)
print(sum(l[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
le=list(map(int,input().split()))
le.sort()
gou=0
for i in range(b):
  gou+=le.pop()
print(gou)

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 = 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(reverse=True)
print(sum(L[: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 = [int (x) for x in input().split()]
list.sort (l)
x = 0
for i in range (K):
  x += l[-i-1]
print (x)

Submission status: Accepted

Solution code:
N,K = map(int,input().rstrip().split(" "))
I = list(map(int,input().rstrip().split(" ")))
I.sort(reverse = True)
ans = 0
for i in range(K):
    ans += I[i]
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 = sorted(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_sorted = sorted(l, reverse = True)
snake = 0
for i in range(k):
    snake += l_sorted[i]
print(snake)

Submission status: Accepted

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

print(sum(i[-b:]))

Submission status: Accepted

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

L.sort() 
L_len = len(L) 
print(sum(L[-k:]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = [int(ln) for ln 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)

length = sum(l[0 : k])

print(length)

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, k = i_map()
    num_list = i_list()

    num_list.sort(reverse=True)

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

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

Submission status: Accepted

Solution code:
#
# abc067 b
#
import sys
from io import StringIO
import unittest


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

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

    def test_入力例_2(self):
        input = """15 14
50 26 27 21 41 7 42 35 7 5 5 36 39 1 45"""
        output = """386"""
        self.assertIO(input, output)


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


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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = map(int, input().split())
print(sum(sorted(l)[::-1][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 = [int(n) for n in input().split()]

print(sum(sorted(L)[N-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[0: K]))

  
if __name__ == "__main__":
  	main()

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 = sorted(l)

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()
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=sorted(L,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()
x = 0
for i in range(1,k+1,1):
    x += l[-i]
print(x)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, k = rm()
li = sorted(rl(), reverse=True)
print(sum(li[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, k = M()
l = LI()
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, raw_input().split())
ais = map(int, raw_input().split())
ais.sort()
print sum(ais[-k:] or [0])

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[-i-1]
print(ans)

Submission status: Accepted

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

rev_sorted_A = list(reversed(sorted(A)))
print(sum(rev_sorted_A[:K]))

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, readline().split())
    L = list(map(int, readline().split()))
    L.sort(reverse=True)
    ans = 0
    for l in L[:K]:
        ans += l
    print(ans)


if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
ls = list(map(int,input().split()))
ls.sort(reverse = True)
print(sum(ls[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]))