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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

rods.sort()
rods.reverse()

A=rods[:K]

print(sum(A))

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum([length[i] for i in range(k)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

n, k = nm()
l = nl()

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

ans = 0
for i in range(K):
	m = max(l)
	ans += m
	l[l.index(m)] = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
t,l=open(0);print(sum(sorted(map(int,l.split()))[-int(t[2:]):]))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    L = list(map(int, input().split()))

    L = sorted(L, key=lambda x: -x)

    return sum(L[:K])


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

Submission status: Accepted

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

numbers.sort()
numbers.reverse()
result = sum(numbers[:K])

print(result)

Submission status: Accepted

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

hoge.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
ls=list(map(int,input().split()))
length=0
for i in range(k):
  length+=max(ls)
  del ls[ls.index(max(ls))]
print(length)

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
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
a,b = LI()
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
    print("Possible")
else:
    print("Impossible")
"""
#B
n,k = LI()
l = LI()
l.sort(reverse = True)
print(sum(l[:k]))
#C
"""
n = I()
a = LI()
b = [None for i in range(n-1)]
for i in range(n-1):
    a[i+1] += a[i]
for i in range(n-1):
    b[i] = abs(2*a[i]-a[n-1])
print(min(b))
"""

#D
"""
n = I()
v = [[] for i in range(n)]
for i in range(n-1):
    a,b = LI()
    a -= 1
    b -= 1
    v[a].append(b)
    v[b].append(a)
d_f = [-1 for i in range(n)]
q = deque()
q.append(0)
d_f[0] = 0
while q:
    x = q.pop()
    for y in v[x]:
        if d_f[y] == -1:
            d_f[y] = d_f[x] + 1
            q.append(y)
d_s = [-1 for i in range(n)]
q.append(n-1)
d_s[n-1] = 0
while q:
    x = q.pop()
    for y in v[x]:
        if d_s[y] == -1:
            d_s[y] = d_s[x] + 1
            q.append(y)
f = 0
s = 0
for i in range(n):
    if d_f[i] <= d_s[i]:
        f += 1
    else:
        s += 1
if f > s:
    print("Fennec")
else:
    print("Snuke")
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

L.sort(reverse=True)

print(sum(L[:k]))

Submission status: Accepted

Solution code:
def snake_toy(N: int, K: int, l: list)->int:
    return sum(sorted(l)[-K:])


if __name__ == "__main__":
    N, K = map(int, input().split())
    l = [int(s) for s in input().split()]
    ans = snake_toy(N, K, l)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
# 067 B
N,K= map(int,input().split())
L=[int(j) for j in input().split()]
L.sort(reverse=True)
print(sum(L[0:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
l = list(map(int,input().split()))
slide = N - K + 1
Max = sum(l[:K])
Sum = 0
count = 0
m = sorted(l)

for i in range(0,slide):
        Sum = sum(m[i:K+i])
        if Max < Sum:
                 Max = Sum
print(Max)

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(a[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

ls.sort()
ans = sum(ls[-K:])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
ans = sum(A[:K])
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(sum(l))

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=[int(i) for i in input().split()]
l=list(reversed(sorted([int(i) for i in input().split()])))
print(sum(l[:k]))

Submission status: Accepted

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

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

for i in range(K):
  sum += l.pop(-1)
print(sum)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Mar  2 02:34:54 2019

@author: yuta
"""

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

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

main(N,K,L)

Submission status: Accepted

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

l = list(reversed(sorted(l)))

print(sum(l[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
n,k= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
a.sort(reverse=1)
print(sum(a[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Snake Toy

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

l.sort(reverse=True)

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

print(total)

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())), reverse=True)
count = 0
length = 0
while count < k:
    length += l[count]
    count += 1
print(length)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

a.sort(reverse=True)

ans=sum(a[0:k])

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 067B
n,k = map(int, input().split())
ll = list(map(int, input().split()))
print( sum(sorted(ll)[-1*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 = 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())
a=sorted(list(map(int,input().split())),reverse=True)
print(sum(a[0:k]))

Submission status: Accepted

Solution code:
# ABC 067 B - Snake Toy

n_k = list(map(int,input().split()))
li = list(map(int,input().split()))
n=n_k[0]
k=n_k[1]

toy = 0
li.sort(reverse=True)

for i in range(k):
    toy += li[0]
    li.pop(0)
print(toy)

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
l = sorted(list(li()), reverse=True)
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:

N ,K = map(int,input().split())
L = list(map(int,input().split()))
L = sorted(L)[::-1]
ans = 0
for i in range(K):
    ans = ans + L[i]
print(ans)

Submission status: Accepted

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

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())
L = [int(l) for l 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 = sorted(l,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)
print(sum(l[:k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
int_n, int_k = map(int, input().split())
ar_int_l = list(map(int, input().split()))

print(sum(sorted(ar_int_l, reverse=True)[:int_k]))

Submission status: Accepted

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

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

ls = sorted(l)[::-1]
ans = sum(ls[:X])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    l.sort(reverse=True)

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


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

Submission status: Accepted

Solution code:
l1 = input().split()
N, K = map(int, l1)
max  = K+1
l2 = input().split()
l2 = list(map(int, l2))

l3 = sorted(l2)
sum = 0


for i in range(1, max) :
    sum += l3[-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)

print(sum(l[:k]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, k = LI()
L = LI()

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

length = sum(l_sort[:K:])
print(length)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# ABC 067
def getIntList(): return [int(x) for x in input().split()]
def db(x): 
    global debug
    if debug: print(x)
debug = False
N,K = getIntList()
L = getIntList()
db((N,K))
db(L)
L.sort()
L.reverse()
db(L)
print(sum(L[:K]))

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.pop()
print(ans)

Submission status: Accepted

Solution code:
s=input().split();n=int(s[0]);k=int(s[1]);s=input().split();m=[];ans=0
for i in s:
    m.append(int(i))
m=sorted(m);m.reverse()
for j in range(0,k):
    ans+=m[j]
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
lists = list(map(int, input().split()))
# 降順ソート
lists.sort(reverse=True)
sum = 0
for i in range(K):
  sum+=lists[i]
print(sum)

Submission status: Accepted

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

l = [int(i) for i in input().split()]
l1 = sorted(l,reverse=True)
ans = 0
for i in range(k):
 ans += l1[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)
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()))
print(sum(sorted(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:
a,b=[int(i) for i in input().split()]
s=[int(i) for i in input().split()]
s.sort()
#print(s)
ans=0
for i in range(b):
  ans+=s[-1-i]
  
print(ans)

Submission status: Accepted

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