Problem:


Score : 200 points

Problem Statement

Snuke has N sticks.
The length of the i-th stick is l_i.

Snuke is making a snake toy by joining K of the sticks together.

The length of the toy is represented by the sum of the individual sticks that compose it.
Find the maximum possible length of the toy.

Constraints

1 \leq K \leq N \leq 50

1 \leq l_i \leq 50

l_i is an integer.

Input

Input is given from Standard Input in the following format:

N K
l_1 l_2 l_3 ... l_{N}

Output

Print the answer.

Sample Input 1

5 3
1 2 3 4 5

Sample Output 1

12

You can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.

Sample Input 2

15 14
50 26 27 21 41 7 42 35 7 5 5 36 39 1 45

Sample Output 2

386



Sample input:
5 3
1 2 3 4 5


Sample output:
12

Submission status: Accepted

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

LL = sorted(L, reverse=True)

sm = 0
for i in range(k):
    sm += LL[i]
print(sm)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K,*L = map(int, read().split())
L.sort()
print(sum(L[len(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:
arr = input().split()
n = int(arr[0])
k = int(arr[1])

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

l.sort()

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

Submission status: Accepted

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

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:
#!/usr/bin/env python3
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())
array = sorted(list(map(int, input().split())), reverse = True)
print(sum(array[0:K]))

Submission status: Accepted

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

for i in range(len(la)-k, len(la)):
    ans += la[i]

print(ans)

Submission status: Accepted

Solution code:
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N, K = getInput();
a_i = getInput()

a_i.sort(reverse=True)
sums = 0

for i in range(K):
    sums += a_i.pop(0)
print(sums)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    L=LIST()
    L=sorted(L, reverse=True)
    print(sum(L[0:k]))
if __name__ == '__main__':
    do()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())
N,K= splitintinput()
l = listintinput()

l.sort(reverse=True)
ans = 0
for i in range(K):
    ans += l.pop(0)

print(ans)

Submission status: Accepted

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

print(sum)
# print(l)

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
l = LIST()

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

lens = sorted(lens)[::-1]

if len(lens) <= K:
    print(sum(lens))
else:
    print(sum(lens[:K]))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N,K = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
l.reverse()
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)
result = sum(l[:K])
print(result)

Submission status: Accepted

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

sList = sorted(list(map(int,input().split())),reverse=True)

length = 0
for i in range(k):
  length += sList[i]

print(length)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ls = sorted([int(i) for i in input().split()])[::-1]

print(sum(ls[: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[i] for i in range(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())
L = list(map(int, input().split()))

## Lを降順に並び替える
# L_desc = sorted(L, reverse=True)

# 別解
L_desc = []
while len(L) > 0:
  maxVal = 0
  for i in range(len(L)):
    if L[i] > maxVal:
      maxVal = L[i]
  L_desc.append(maxVal)
  L.remove(maxVal)

snakeLength = 0
for l in range(K):
  snakeLength += L_desc[l]

print(snakeLength)

Submission status: Accepted

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

sorted_l = sorted(l, reverse=True)

max_len = 0
for i in range(K):
    max_len += sorted_l[i]

print(max_len)

Submission status: Accepted

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

L_desc = sorted(L, reverse=True)

snakeLength = 0
for l in range(K):
  snakeLength += L_desc[l]

print(snakeLength)

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:
import sys
input = sys.stdin.readline

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:
# AtCoder Beginner Contest 067 - B
# -*- encoding: UTF-8 -*-

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

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

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(sum(l[:K]))

Submission status: Accepted

Solution code:
x,y = map(int,input().split())
li = list(map(int,input().split()))

max = 0

newLi = sorted(li, reverse=True)

for i in range(y):
  max += newLi.pop(0)

print(max)

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
input = sys.stdin.readline

N, K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
l = sorted(l, 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, reverse=True)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

res = 0

for _ in range(k):
    res += l.pop(l.index(max(l)))
print(res)

Submission status: Accepted

Solution code:
import sys


def solve(inp):
    (N, K) = map(int, inp.readline().split(' '))
    L = list(reversed(sorted(map(int, inp.readline().split(' ')))))

    r = 0
    for i in range(K):
        r += L[i]

    return str(r)


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
T = list(map(int,input().split()))
ans=0
for i in range(K):
    p=max(T)
    ans=ans+p
    s=T.index(max(T))
    T.pop(s)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
l = sorted(map(int, input().split()), reverse=True)

print(sum(l[:m]))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
#stdin = open("input.txt")

if __name__ == "__main__":
    N, K = [int(item) for item in stdin.readline().split()]
    li = [int(item) for item in stdin.readline().split()]
    
    li.sort(reverse=True)
    print(sum(li[: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())
li = sorted([int(x) for x in input().split()])
print(sum(li[-k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
N, K = map(int, input().split())
L = list(map(int, input().split()))
#N = int(input())
#S = str(input())

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

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

Submission status: Accepted

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

l.sort()
tmp = 0
for i in range(n - k):
    tmp += l[i]
ans = sum(l) - tmp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a = input().split()
ss = list(input().split())
s = []
for i in ss:
    s.append(int(i))
k = 0
for i in range(int(a[1])):
    d = max(s)
    k += d
    s.remove(d)
print(k)

Submission status: Accepted

Solution code:
import sys

n, k, *l = map(int, sys.stdin.read().split())

def main():
    l.sort(reverse=True)
    return sum(l[:k])

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n,k,*l=map(int,open(0).read().split())
l.sort(reverse=True)
print(sum(l[0:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n,k = map(int, sys.stdin.readline().split())

l = list(map(int, sys.stdin.readline().split()))

l.sort()

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

Submission status: Accepted

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

ll = sorted(ll)

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

Submission status: Accepted

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

print(sum(snakes[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

buf=sorted(l,reverse=True)
result=0

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

print(result)

Submission status: Accepted

Solution code:
# B - Snake Toy
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
A.sort(reverse=True)

for i in range(K):
    ans += A[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()]
print(sum(sorted(L)[N - K:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A.sort(reverse=True)

AMAX = A[0:K]

print(sum(AMAX))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,k=MI()
    ll=LI()
    ll.sort(reverse=True)
    print(sum(ll[:k]))
    
main()

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

lst = sorted(lst)
print(sum(lst[-k:]))

Submission status: Accepted

Solution code:
n,k=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
ans=0
for i in range(k):
    ans+=l.pop(l.index(max(l)))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

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


l = sorted(l,reverse=True)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
s=0
for i in range(k):
    a=max(l)
    s+=a
    l.remove(a)
print(s)

Submission status: Accepted

Solution code:



def main()->None:
    (N, K) = map(int, input().split())
    l = list(map(int, input().split()))

    sorted_l = sorted(l, reverse=True)
    s = 0
    for i in sorted_l[:K]:
        s += i

    print(s)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(sum(newList[:k]))

Submission status: Accepted

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

ls_sorted = list(reversed(sorted(ls_l)))

print(sum(ls_sorted[:k]))

Submission status: Accepted

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

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

lst.sort()
print(sum(lst[-k:]))

Submission status: Accepted

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

sort_l = sorted(l, reverse=True)
ans = 0

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

print(ans)

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

Submission status: Accepted

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

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

print(sum(l[a-b:]))

Submission status: Accepted

Solution code:

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

k = sorted(l)

ans = 0

for i in range(K):
    ans += k.pop()

print(ans)

Submission status: Accepted

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

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

print(length)

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

Submission status: Accepted

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

num = sorted(list(map(int, input().split())), reverse = True)

print(sum(num[:k]))

Submission status: Accepted

Solution code:
##### 解けた #####

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin

a,b = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

li.sort(reverse = True)

print(sum(li[:b]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sticks = list(map(int, input().split()))
s = sorted(sticks, reverse=True)

slice_k = s[:k]
print(sum(slice_k))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
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())
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()
ans = 0
for i in range(K):
  ans += L[-(i+1)]
print(ans)

Submission status: Accepted

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

n_sort = sorted(n_list, reverse=True)
n_k = n_sort[0:k]
answer = sum(n_k)
print(answer)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

sorted_Ls = sorted(Ls, reverse=True)
length_sum = 0
for k in range(K):
    length_sum += sorted_Ls[k]
print(length_sum)

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def examB():
    N, K = LI()
    L = LI(); L.sort(reverse = True)
    ans = sum(L[:K])
    print(ans)


import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Accepted

Solution code:
# ABC 067: B – Snake Toy
n, k = [int(s) for s in input().split()]
l = [int(s) for s in input().split()]

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
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:
a,b=list(map(int,input().split()))
c=list(int(i) for i in input().split())  
c.sort(reverse=True)
count=0
for i in range(b):
    count+=c[i]
print(count)