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

Submission status: Accepted

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

L.sort()

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

Submission status: Accepted

Solution code:

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

L.sort(reverse=1)
print(sum(L[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, K = map(int, input().split())
        l = list(map(int, input().split()))

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


if __name__ == '__main__':
    AtCoder().main()

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

Submission status: Accepted

Solution code:
N,K = map(int, input().strip().split(' '))
L = sorted(list(map(int, input().strip().split(' '))))
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
ans=0

#for文で配列から大きい数値をk個取得してansに代入して足し算
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.reverse()

ans=0

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

Submission status: Accepted

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

A.sort(reverse=True)
ans = 0
for k in range(K):
    ans += A[k]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

a.reverse()

length = 0

for x in range(K):
    length += a[x]
    
print(length)

Submission status: Accepted

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

Submission status: Accepted

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

print(he)

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    L = [int(l) for l in input().split()]
    L.sort(reverse = True)
    return sum(L[:K])


if __name__ == '__main__':
    print(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=sorted(list(map(int,input().split())))
print(sum(l[-k:]))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

from functools import reduce
from operator import add

n, k = map(int, input().split())
sticks = list(map(int, input().split()))
sticks.sort(reverse = True)
print(reduce(add, sticks[:k]))

Submission status: Accepted

Solution code:
import sys
N, M = map(int, sys.stdin.readline().rstrip().split())
l = sorted(map(int, sys.stdin.readline().rstrip().split()), reverse = True)
print(sum(l[:M]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
l = [int(s) for s in input().split()]
l.sort()
print(sum(l[-K:]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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:
i, j = [input() for x in range (2)]
K, N = [int(y) for y in i.split(' ')]
arr = sorted([int(y) for y in j.split(' ')], reverse=True)

print(sum(arr[:N]))

Submission status: Accepted

Solution code:
nk = input().split()
n = int(nk[0])
k = int(nk[1])
li = input().split()

for i in range(n):
	li[i] = int(li[i])

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

Submission status: Accepted

Solution code:
L,R = map(int,input().split())
hoge = list(map(int, input().split()))
print(sum(sorted(hoge)[::-1][:R]))

Submission status: Accepted

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

import sys
input = sys.stdin.readline


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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
(n, k) = (int(tok) for tok in input().split())
sticks = sorted(int(tok) for tok in input().split())

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

Submission status: Accepted

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

num = 0
result = 0


for x in a:
    num = num +1
    result = result + x
    if num == K:
        print(result)

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=input().split()
n,k=int(n),int(k)

l=sorted([int(i) for i in input().split()],reverse=True)

print(sum(l[:k]))

Submission status: Accepted

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

ls = sorted(l)[::-1]
sum = 0
for k in ls[:K]:
    sum += k
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:
# -*- coding: utf-8 -*-

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

# solve
l.sort(reverse=True)

# output
print(sum(l[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())) [::-1]
print(sum(l[:k]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
num, req_num = map(int,input().split())
num_array    = sorted(list(map(int,input().split())),reverse=True)
result = 0

for i in range(req_num):
    result += num_array[i]

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

array.sort()

sum = 0
for i in range(k):
  sum += array[-(i+1)]

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

r_L=sorted(L)[::-1]

print(sum(r_L[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

li.sort(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())
ln = map(int,input().split())
print(sum(list(reversed(sorted(ln)))[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Snake Toy

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


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

Submission status: Accepted

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

Submission status: Accepted

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

for _ in range(K):
  length+=l_list.pop()

print(length)

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:
#067B
n,k = list(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)
l=l[:k]
print(sum(l))

Submission status: Accepted

Solution code:
s, k = map(int,input().split())
sticks = sorted([int(i) for i in input().split()],reverse = True)
result_sum = 0

for j in range(k):
    result_sum += sticks[j]

print(result_sum)

Submission status: Accepted

Solution code:

def main():


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

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





    
if __name__== "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


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

    return


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

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
n, k = map(int, input().rstrip("\n").split())
sticks = sorted(map(int, input().rstrip("\n").split()), reverse=True)

print(sum(sticks[:k]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
stick_list = list(map(int, input().split()))
stick_list.sort()
selections = stick_list[-k:]

print(sum(selections))

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(l[:b]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=[int(x) for x in input().split()]
lN=[int(x) for x in input().split()]
lN.sort()
print(sum(lN[N-K:]))

Submission status: Accepted

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

Submission status: Accepted

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

l_list_sorted = sorted(l_list, reverse=True)

print(sum(l_list_sorted[0:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = list(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_max=sorted(l,reverse=True)[:k]
print(sum(l_max))

Submission status: Accepted

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

Submission status: Accepted

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

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

lLst.sort(reverse=True)
ans = 0
for i in range(K):
    ans += lLst[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[-1*k:]))

Submission status: Accepted

Solution code:
# ABC 67, B - snake toy
n, k = [int(el) for el in input().split(' ')]
L = sorted([int(l) for l in input().split(' ')])

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l_list = list(map(int, input().split()))
new_list = []
for i in range(k):
    max_value = l_list.pop(l_list.index(max(l_list)))
    new_list.append(max_value)
print(sum(new_list))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, K: int, l: "List[int]"):
    l = sorted(l)
    print(sum(l[N-K:]))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
N, K = map(int, input().split())
L = map(int, input().split())
print(sum(sorted(L, reverse=True)[:K]))

Submission status: Accepted

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

def main(N,K,L):
    L = sorted(L,reverse=True)
    ans = 0
    for i in range(K):
        ans += L[i]
    print(ans)

if __name__ == '__main__':
    N,K = map(int, input().split())
    L = [int(l) for l in input().split()]
    main(N,K,L)

Submission status: Accepted

Solution code:

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

l.sort()
l.reverse()

s=0

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

print(s)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N,K = inputMap()
    l = inputList()
    
    l.sort()
    ll = l[::-1]
    
    ans = 0
    #print(ll)
    for i in range(K):
        #print(i)
        ans += ll[i]
    
    print(ans)
        
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = list(map(int,input().split()))
l = 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)
sum = 0
for i in range(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(reverse=True)
A = []
for i in range(K):
  A.append(L[i])

print(sum(A))

Submission status: Accepted

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

Submission status: Accepted

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

ls = sorted(l , reverse= True)

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

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)
result = 0

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

print(result)

Submission status: Accepted

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

l_list.sort()
print(sum(l_list[-K:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if not (a % 3 and b % 3 and (a + b) % 3):
        print("Possible")
    else:
        print("Impossible")
    return

#B
def B():
    k, n = LI()
    l = LI()
    l.sort(reverse = True)
    print(sum(l[:n]))
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()

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:
inp = list(map(int, input().split()))
N = inp[0]
K = inp[1]
lengs = list(map(int, input().split()))
lengs.sort(reverse=True)
result = 0

for i in range(K):
    result += lengs[i]

print(result)

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(N):
    if K != 0:
        ans += l[i]
        K -= 1
    elif K == 0:
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = list(map(int ,input().split()))
c = sorted(c, reverse=True)
print(sum([c[i] for i in range(b)]))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

l = sorted(l)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l_sorted = sorted(l_list, reverse=True)
l_sum = 0
for i in range(k):
    l_sum += l_sorted[i]

print(l_sum)

Submission status: Accepted

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

Submission status: Accepted

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

li.sort(reverse=True)

ans = sum([li[i] for i in range(0,k)])
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, typ=int):
    return [typ(input()) for _ in range(n)]

def main():
    n, k = read_h()
    l = sorted(read_h(), reverse=True)
    print(sum(l[:k]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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