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:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

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

Submission status: Accepted

Solution code:
#ABC 067 B - Snake Toy
N,K = map(int,input().split())
ln = list(map(int,input().split()))

an = []
for i in range(K):
    an.append(max(ln))
    del ln[ln.index(max(ln))]

k = 0 
for i in range(len(an)):
    k += an[i]

print(str(k))

Submission status: Accepted

Solution code:
n, k = input().split()
l = input().split()
L = []
for hoge in l:
  L.append(int(hoge))
L.sort()
L.reverse()
sum = 0
for i in range(int(k)):
  sum += L[i]
print(sum)

Submission status: Accepted

Solution code:
import heapq
N, K = map(int, input().split())
L = list(map(int, input().split()))
print(sum(heapq.nlargest(K,L)))

Submission status: Accepted

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

print(sm)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  N, K = map(int, input().split())
  L = list(map(int, input().split()))
  L.sort(reverse=True)
  ans = sum(L[:K])
  return ans
print(solve())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
l = sorted(list(MAP()), reverse=True)

print(sum(l[:K]))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(length)

Submission status: Accepted

Solution code:
N,K = (int(T) for T in input().split())
L = sorted([int(T) for T in 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()))

ls = sorted(l,reverse = 1)

print(sum(ls[:K]))

Submission status: Accepted

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

l = input().split()

l_i = []
for s in l:
    l_i.append(int(s))
    
l_i.sort(reverse = True)

l_s = l_i[:K]

print(sum(l_s))

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(l[:k]))

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *L = map(int, read().split())

    L.sort(reverse=True)

    print(sum(L[:K]))

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(l[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(total)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
MM = input().split()
N = int(MM[0])
K = int(MM[1])
LL = input().split()
list1 =[]
for i in LL:
  a = int(i)
  list1.append(a)
list1.sort(reverse = True)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def actual(N, K, L):
    return sum(sorted(L)[-K:])

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

print(actual(N, K, L))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().split()

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

snakes = []

p = input().split()
for i in range(n):
    q = int(p[i])
    snakes.append(q)

snakes.sort()

answer = 0

for i in range(k):
    x = snakes.pop()
    answer += x

print(answer)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
line = list(map(int,input().split()))
line.sort(key=int)
count = -1
output = 0
for _ in range(k):
    output += line[count]
    count += -1
print(output)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(l[:K]))

Submission status: Accepted

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


print(L)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(lst[:-k-1:-1]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k = map(int, input().split())
l = sorted(list(map(int, input().split())))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
l = [int(x) for x in input().split()]
ans = 0
for _ in range(K):
    m = max(l)
    ans += m
    m_i = l.index(m)
    l[m_i]=0

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,K = I()
L = l()
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[n-k:]))

Submission status: Accepted

Solution code:
data = [int(i) for i in input().split(' ')]
K = data[1]
ls = sorted([int(i) for i in input().split(' ')], reverse=True)

l_sum = 0
for k in range(K):
    l = ls[k]
    l_sum += l

print(l_sum)

Submission status: Accepted

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N , K  = map(int,input().split())
l = [int(x) for x in input().split()]
l = sorted(l)
猫 = 100
# l = reversed(l)
l.reverse()
for i in range(K):
  猫 += l[i]
print(猫-100)

Submission status: Accepted

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

l_list.sort(reverse=True)

new_list=l_list[:k]
print(sum(new_list))

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:
# -*- coding: utf-8 -*-

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

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

Submission status: Accepted

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

a = sorted(length, reverse=True)
b = a[0:K]
print(sum(b))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l.sort(reverse=True)

snake = 0

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

print(snake)

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:
import sys
N,K = map(int,input().split())
int_array = list(map(int,input().split()))

if N < 0 or K < 0 or N > 50 or K > 50:
    sys.exit()
for I in int_array:
    if I > 50:
        sys.exit()

rev_sort_int_array = sorted(int_array,reverse=True)
result = 0
for J in range(K):
    result += rev_sort_int_array[J]

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N, K = mi()
    l = list(mi())
    l.sort(reverse=True)
    print(sum(l[:K]))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

l_sort = sorted(l, reverse=True)

# print(l_sort)
a =0
for i in range(K):
    a += l_sort[i]
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations

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

Submission status: Accepted

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

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

print(c)

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

Submission status: Accepted

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

print(sum(L[:K]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def calclength(N, K, length) :
  length.sort(reverse = True)
  lengthsum = 0
  for i in range(K) : 
    lengthsum += length[i]
    
  return lengthsum

N, K = tuple(map(int, input().split()))

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

print(calclength(N, K, length))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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()))
l=0
for i in range(k):
  l+=max(a)
  a.remove(max(a))

print(l)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

    return ans

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

Submission status: Accepted

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

L.sort()
ans = sum(L[-k:])
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:
def main():
    N, K = map(int,input().split())
    a = list(map(int,input().split()))
    a.sort(reverse=True)
    ans = sum(a[:K])
    print(ans)
    return
main()

Submission status: Accepted

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

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 += l[i]

print(ans)