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

Submission status: Accepted

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

result = 0

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

print(result)

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

#リストのstrをintに変換
for i in range(len(stick)):
	stick[i]=int(stick[i])
#print(stick)
#変換ここまで

#大きいうちからk本の棒の合計を求めるため、ソートする。
stick=sorted(stick,reverse= True)
#print(stick)

#ソートしたリストの大きい側からk個の数値を足し合わせる
a=0
a=int(a)
for i in range(k):
	a=a+stick[i]
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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


print(sum(waw[0:M]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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 = [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())
sticks = list(map(int, input().split()))
sticks.sort(reverse=True)

res = 0
for i in range(K):
    res += sticks[i]
print(res)

Submission status: Accepted

Solution code:
lis = input().split(' ')
N= int(lis[0])
L = int(lis[1])

l = input().split(' ')
for i in range(N):
    l[i] = int(l[i])
l.sort()

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

print(ans)

Submission status: Accepted

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

length.sort(reverse=True)
snake_length = 0

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

print(snake_length)

Submission status: Accepted

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

l.sort(reverse=True)

print('{}'.format(sum(l[:k])))

Submission status: Accepted

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

Submission status: Accepted

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

l = []
for i in range(N):
    l.append(int(lchar[i]))


total = 0

for i in range(K):
    total = total + max(l)
    l.remove(max(l))

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(l)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

L = list(map(int,input().split()))[:N]

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

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

n,k = list(map(int, stdin.readline().split()))
l = list(map(int, stdin.readline().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()))
a = sorted(l)
ans = 0
for i in range(K):
    ans += a[-(i+1)]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if len(l) > k:
    print(sum(sorted(l)[-k:]))
else:
    print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
k = int(arr_data[0][1])

arr01=arr_data[1]

arr02=sorted(list(map(int, arr01)),reverse=True)

#print(n,k,arr02)

mysum=0
for v in range(0,len(arr02)):

    if(v!=k):
        mysum+=arr02[v]
   
        
    else:
        break
print(mysum)

Submission status: Accepted

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

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

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    total_bar_count, choosed_bar_count = list(map(int, input().split()))
    bar_lengths = list(map(int, input().split()))

    bar_lengths.sort(reverse=True)
    total_bar_length = sum(bar_lengths[:choosed_bar_count])
    print(total_bar_length)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
num = [0]*N
tmp = input().split()
for i in range(N):
  num[i] = int(tmp[i])
num.sort(reverse=True)
sum = 0
for j in range(K):
  sum += num[j]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
NK = raw_input()
li = raw_input()

N = int(NK.split()[0])
K = int(NK.split()[1])
li_list = li.split()
li_list = map(int, li_list)

cut_list = sorted(li_list, key=int, reverse=True)[0:K]


print(sum(cut_list))

Submission status: Accepted

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

for i in range(k):
    ans += max(l)
    l.remove(max(l))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=input().split()
a=input().split()
a=[int(k) for k in a]
sum=0
a=sorted(a)[::-1]
for i in range(int(k)):
    sum+=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)
T=0
for i in range(K):
    T+=l[i]

print(T)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=[int(i) for i in 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()
print(sum(l[0:k]))

Submission status: Accepted

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

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:

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k=int(input().split()[1])
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()
l.reverse()
print(sum(l[0:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l.sort()
l = list(reversed(l))
print(sum(l[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = [int(x) for x in input().split()]
stick = [int(x) for x in input().split()]

stick = sorted(stick)

ret = 0
for i in reversed(range(len(stick)-num[1], len(stick))):
    ret += stick[i]
print(ret)

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:
#!/usr/bin/env python

N,K=list( int(i) for i in input().split() )
l=list( int(i) for i in input().split() )

l.sort()
l.reverse()

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

print(N)

Submission status: Accepted

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

Submission status: Accepted

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

x = sorted(x, reverse=True)

summation = 0

for i in range(k):
    summation += x[i]

print(summation)

Submission status: Accepted

Solution code:
N, K = list(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())
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(reverse=True)

ans = sum(L[:K])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: utf-8
n, k = [int(i) for i in input().split()]
l  = [int(x) for x in input().split()]

l.sort()
l.reverse()

re = 0
for i in l[:k]:
   re += i

print(re)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l.sort(reverse = True)

print(sum(l[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://abc067.contest.atcoder.jp/tasks/abc067_b

"""
import sys
from sys import stdin

input = stdin.readline


def main(args):
    N, K = map(int, input().split())
    rods = [int(x) for x in input().split()]
    rods.sort()
    snake = rods[-K:]
    print(sum(snake))


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
x = input().split()
y = input().split()
x = [int(x) for x in x]
y = [int(y) for y in y]
y = sorted(y,reverse=True)
i = 0 
j = 0
for num in y:
    i=i+num
    j+=1
    if j==x[1]:
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():  # 068B - Snake Toy
    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]))


solve()

Submission status: Accepted

Solution code:
n, k = [int(x) for x in input().split()]
l = [int(y) for y 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()))
l.sort()
l_new=l[::-1][:k]
print(sum(l_new))

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(reverse=True)
ans = 0
for i in range(K):
    ans += L[i]
print(ans)

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    l_list = sorted([int(i) for i in input().split()], reverse=True)
    print(sum(l_list[: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=1)
ans=0
for i in range(K):
  ans+=L[i]
print(ans)

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

Submission status: Accepted

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

sum = 0
for i in range(int(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()

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def Q2(x):
    N, K = x[0][0], x[0][1]
    lst = x[1][:]
    lst = sorted(lst)[::-1]
    return sum(lst[:K])

l = [int(i) for i in input().split()]
m = [int(i) for i in input().split()]
n = [l,m]
print(Q2(n))

Submission status: Accepted

Solution code:
t = raw_input().split()
a = int(t[0])
b = int(t[1])
l = map(int, raw_input().strip().split())
l.sort()
l = l[::-1]
ans = 0
for x in range(b):
	ans += l[x]
print(ans)

Submission status: Accepted

Solution code:

N, K = map(int, input().split())
lens = [int(e) for e in input().split()]
lens.sort()
lens.reverse()

print(sum(lens[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
cnt = 0
ans = 0
l.sort()
for i in reversed(l):
    if cnt < k:
        ans += i
        cnt += 1
    else:
        break
print(ans)

Submission status: Accepted

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

n_k = raw_input()
n_k = n_k.split()
n_k = map(int,n_k)
n = n_k[0]
k = n_k[1]

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

ans = 0
i = 0
while i < k:
    max_len = max(l)
    ans += max_len
    l[l.index(max_len)] = 0
    i += 1

print ans

Submission status: Accepted

Solution code:
#!/usr/bin
# -*- cording: "utf-8" -*-
 
a, b = map(int, input().split())
c = list(map(int, input().split()))
c.sort(reverse=True)
x = 0
for i in range(b):
  x = x + c[i]
print(x)

Submission status: Accepted

Solution code:
def snake_toy():
	n, k = map(int, raw_input().split(" "))
	l = list(map(int, raw_input().split(" ")))
	sorted_l = sorted(l, reverse=True)
	print sum(sorted_l[:k])


if __name__ == "__main__":
	snake_toy()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print SUM

Submission status: Accepted

Solution code:

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

N = a[0]
K = a[1]
sub = N - K

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


for i in range(sub):
    b.pop(b.index(min(b)))
    
print(sum(b))

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
N=int(b[0])
K=int(b[1])
ans=[]
c=input()
l=c.split(" ")
l1=map(int,l)
l2=list(l1)
for w in range(K):
    ans.append(max(l2))
    max_idx = l2.index(max(l2))
    del l2[max_idx]
print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
N, K = map(int, input().split())
L =list(map(int, input().split()))
 
a = sorted(L)
 
print(sum(a[-K:]))

Submission status: Accepted

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

lsort = sorted(l, reverse=True)

lsum = 0
for i in range(k):
    lsum = lsum + lsort[i]
print(lsum)

Submission status: Accepted

Solution code:
line = input().split()
N = int(line[0])
K = int(line[1])
l = sorted(map(int, input().split()), key=lambda x: -x)
ans = 0

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

print(ans)

Submission status: Accepted

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

import sys

input_line = sys.stdin.readline().split(' ')
n = int(input_line[0])
k = int(input_line[1])

input_line = sys.stdin.readline().split(' ')
l_list = list(map(int, input_line))

l_list.sort(reverse=True)

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

print(l)

Submission status: Accepted

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

print(goukei)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
long = [int(i) for i in input().split()]
long = sorted(long, reverse = True)
print(sum(long[0: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 = list(map(int, input().split()))
L = list(map(int, input().split()))
L.sort()
print(sum(L[-1:-K-1:-1]))

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(0, K):
	ans += L[i]
print(ans)

Submission status: Accepted

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

print sum(numbers[-k:])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

n, k = rli()
s = rli()
s.sort(reverse=True)
print(sum(s[:k]))

Submission status: Accepted

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

nums.sort()
nums.reverse()
ans=list()

for v in range(k):
    ans.append(nums[v])

print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l = [int(j) for j in input().split()]

l = sorted(l)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
list = input().rstrip().split()
N = int(list[0])
K = int(list[1])
list2 = input().rstrip().split()
a = []
for i in range(N):
    a = a + [int(list2[i])]
a.sort()
sum = 0
for i in range(K):
    sum = sum + a[N-1-i]
print(sum)

Submission status: Accepted

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

l.sort(reverse=True)

A=0

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

print(A)

Submission status: Accepted

Solution code:
i = input().split()
l = list(map(int, input().split()))
n = int(i[0])
k = int(i[1])

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()
sum=0
for i in range(0,k):
    sum += l.pop()
 
print(sum)

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

Submission status: Accepted

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

Submission status: Accepted

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