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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem B - Snake Toy

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

# initialization
max_cost = 0
l_list = sorted(l_list, reverse=True)

# max
max_cost = sum(l_list[:K])
print(max_cost)

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    L = [int(l) for l in input().split()]
    L.sort(reverse = True)
    print(sum(L[:K]))
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
l = na()
l = sorted(l)

print(sum(l[n-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:]))

Submission status: Accepted

Solution code:
# デバッグ用
GBN_DEBUG = False
GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)

#本体ここから

#S = input()
#N = int(input())
#S, T = input().split()
N, K = map(int, input().split())
#W = [input() for _ in range(N)]
l = list(map(int, input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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:
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:
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:
n,k=map(int,input().split())
L = sorted(list(map(int,input().split())))[::-1]
print(sum(L[0:k]))

Submission status: Accepted

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

snake = 0
lst.sort(reverse=True)

for num in range(0, k):
    snake += lst[num]

print(snake)

Submission status: Accepted

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

l = list(map(int,input().split()))
s = 0
for i in range(K):
    a = max(l)
    s += a
    l.remove(a)

print(s)

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

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

Submission status: Accepted

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

length.sort(reverse=True)
for i in range(K):
  max_length += length[i]
  
print(max_length)

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()))
sort_a = sorted(l, reverse=True)
sum = 0

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

print(sum)

Submission status: Accepted

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

stics = [int(i) for i in input().split()]

stics = sorted(stics, reverse=True)

print(sum(stics[:K]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l=sorted(l,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:
import sys

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

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

# l.sort()

# max_length = 0
# for item in l[n-1:n-k-1:-1]:
#     max_length += item

# print("{}".format(max_length))

l.sort(reverse=True)

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

print("{}".format(max_length))

Submission status: Accepted

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

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

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:
#abc067 b
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
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, K: int, l: "List[int]"):
    l.sort(reverse=True)
    print(sum(l[:K]))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, l)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():

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

    print(sum([L[i] for i in range(K)]))


resolve()

Submission status: Accepted

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

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

list.sort()
list.reverse()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

sum = sum(l)
for i in range(N-K):
    sum-=l[i]
print(sum)

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,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())
li = list(map(int, input().split()))
li.sort(reverse=True)
length = sum(li[x] for x in range(k))
print(length)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
l=input().split()
numbers=[int(a) for a in l]
answers=sorted(numbers,reverse=True)
list=[]
for b in range(K):
    list.append(answers[b])
print(sum(list))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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 = input()
n = n.split(" ")
n = list(map(int, n))
len_ = n[1]

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


length.reverse()
len_max = length[0 : len_]
max_ = sum(len_max)

print(max_)

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:
k = int(input().split()[1])
sticks = sorted(map(int,input().split()),reverse=True)

total = 0

for i in range(k):
    total += sticks[i]

print(total)

Submission status: Accepted

Solution code:
k = int(input().split()[1])
sticks = sorted(list(map(int,input().split())),reverse=True)

total = 0

for i in range(k):
    total += sticks[i]

print(total)

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:
# coding: utf-8
# Your code here!
N, K  = map(int,input().split())
L = list(map(int,input().split()))
L.sort(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.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()))[-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:]))

Submission status: Accepted

Solution code:
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    n,k =map(int, input().split())
    l = list(map(int, input().split()))
    l = sorted(l, reverse=1)
    res = 0
    for i in range(k):
        res += l[i]
    print(res)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
l=sorted(map(int,input().split()),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=sorted(l)
total=0
t_ans=0
for i in range(N):
    total+=l[i]
for i in  range(N-K):
    t_ans+=l[i]
print(total-t_ans)

Submission status: Accepted

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

Submission status: Accepted

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

L = sorted(L, reverse=True)

total = 0
for k in range(K):
  total += L[k]
  
print(total)

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(reverse = True)
res = 0
for i in range (k):
    res += l[i]
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    l=LI()
    l.sort(reverse=True)
    ans=sum(l[:K])
    print(ans)

main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
I = list(map(int, input().split()))
N, K = I[0], I[1]

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

MAX = 0
for i in range(K):
  MAX += ls[i]
  
print(MAX)

Submission status: Accepted

Solution code:
#067_B
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())

l = sorted(map(int, input().split()))[::-1]

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

Submission status: Accepted

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

Submission status: Accepted

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

dct = sorted(L, reverse=True)

ans = []

for i in range(K):
    ans.append(dct[i])

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

Submission status: Accepted

Solution code:
n, k = [int(e) for e in input().split()]
sticks_length = list(map(int, input().split()))
sticks_length.sort(reverse=True)
print(sum(sticks_length[:k:1]))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
L=list(map(int,input().split()))
stick=[0]*K
for l in L:
    minimum=min(stick)
    if l>minimum:
        stick.remove(minimum)
        stick.append(l)
print(sum(stick))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(1,K+1):
    m = m + A[-i]
    
print(m)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    sticks, join_num = map(int, input().split())
    length = list(map(int, input().split()))
    length.sort(reverse=True)
    print(sum(length[:join_num]))


if __name__ == '__main__':
    main()

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

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

Submission status: Accepted

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

lists = [int(i) for i in input().split()]

lists.sort(reverse=True)

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

A.sort()
A.reverse()

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

Submission status: Accepted

Solution code:
n,k=list(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())

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

A = sorted(A)

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

Submission status: Accepted

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

Submission status: Accepted

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


n,k = list(map(int, input().rstrip().split()))
l_list = list(map(int, input().rstrip().split()))
#----------
l_list.sort(reverse=True)

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

print(sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
[N, K] = list(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(length)

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split(" ")]
lst = [int(i) for i in input().split(" ") ]

lst.sort(reverse = True)

print(sum(lst[:K]))

Submission status: Accepted

Solution code:
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
l = na()

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)
print(sum(l[: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(k):
  ans += l[-1-i]
print(ans)

Submission status: Accepted

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

l_new = sorted(l, reverse = True)

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

print(str(sum))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def snaketoy(n , k , l):

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

    return ans

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
try:
    N, K = map(int, input().split())
    _ = list(map(int, input().split()))
    __ = sorted(_, reverse = True)
    print(sum(__[0:K]))
except EOFError:
    pass

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l_i = input().split()
list = []
for x in range(n):
	list.append(int(l_i[x]))
list.sort()
answer = 0
for id in range(k):
	answer += list[n - (id + 1)]
print(answer)

Submission status: Accepted

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


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__":
    main()

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

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

Submission status: Accepted

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

l = sorted(l, key= lambda x: -x)
print(sum(l[0: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()
L = L[::-1]
res = 0

for i in range(k):
    res += L[i]

print(res)

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,k = inpm()
    l = inpl()
    l.sort()
    l.reverse()
    ans = 0
    for i in range(k):
        ans += l[i]
    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

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:
kazu, pick = map(int, input().split())
nagasalist = list(map(int, input().split()))
dst = sum(sorted(nagasalist)[-pick:])
print(dst)

Submission status: Accepted

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

Submission status: Accepted

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

a_list = sorted(a_list, reverse=True)

ans = 0

for i in range(k):
	ans = ans + a_list[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:]))