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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem:
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


def II(): return int(sys.stdin.readline())


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 solver(selectNum, snakeLongList):
    result = 0
    sortedSnakeLongList = sorted(snakeLongList, reverse=True)
    for j in range(0, selectNum, +1):
        result = result + sortedSnakeLongList[j]
    # algorithm
    return result


if __name__ == "__main__":
    _, K = MI()
    LongI = LI()
    print("{}".format(solver(K, LongI)))

Submission status: Accepted

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

def main():
    N, K = map(int, readline().rstrip().split())
    L = list(map(int, readline().rstrip().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())))[::-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())
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, = map(int, input().split())

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

Submission status: Accepted

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

print(sum(li[:y]))

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

Submission status: Accepted

Solution code:
from sys import stdin
import math

[N, K] = list(map(int, stdin.readline().rstrip().split()))
l = list(map(int, stdin.readline().rstrip().split()))
l_sorted = sorted(l, reverse=True)

total_length=0
for i in range(K):
    total_length += l_sorted[i]

print(total_length)

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
num = list(map(int,input().split()))   
num.sort()
num=num[-b:]

print(sum(num))

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/abc067/tasks/abc067_b
# Python 1st Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


def II(): return int(sys.stdin.readline())


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 solver(selectNum, barLongth):
    result = 0
    barLongth.sort(reverse=True)
    #   print("{}".format(barLongth))
    # algorithm
    j = 0
    while j < selectNum:
        result = result + barLongth[j]
        j = j + 1
    return result


if __name__ == "__main__":
    _, K = MI()  # Nは要らない
    LII = LI()
    print("{}".format(solver(K, LII)))

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 = [int(i) for i in input().split()]
sorted_L = sorted(L, reverse=True)

max = 0
for i in range(K):
    max += sorted_L[i]

print(max)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

b=sum(a)
for i in range(n-k):
    b-=a[i]

print(b)

Submission status: Accepted

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

Submission status: Accepted

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

ans = list(sorted(L))[::-1]
ans = sum(ans[0:k])
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# solution

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

Submission status: Accepted

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

M = 0

L.sort(reverse=True)

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

print(M)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

length = sorted(length, reverse=True)

print(sum(length[:K]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=sorted(map(int,input().split()),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:
# ABC 067: B – Snake Toy
n, k = map(int, input().split())
l = [int(s) for s in input().split()]
l.sort()
print(sum(l[k * (-1):]))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    L = sorted(il())[::-1]
    print(sum(L[0:K]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
tot,sel=(int(x) for x in input().split())
al=[]
aa=(int(x) for x in input().split())

for i in aa:
  al.append(i)

al.sort()  

print(sum(al[-sel:]))

Submission status: Accepted

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

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

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 = s + l.pop(0)
print(str(s))

Submission status: Accepted

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

print(length)

Submission status: Accepted

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

l.sort()
ans=0

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

Submission status: Accepted

Solution code:
import sys
 
N, K = map(int, sys.stdin.readline().split(" "))
L = sorted(list(map(int, sys.stdin.readline().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()))
count = 0
l = sorted(l, reverse=True)
for i in range(k):
     count += l[i]
print(count)

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

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

print(ans)

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

Submission status: Accepted

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

l.sort()
print(sum(l[n - k:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    L = [int(l) for l in input().split()]
    L.sort(reverse = True)
    print(sum(L[:K]))

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    ABC67_B()

"""

"""

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc067/tasks/abc067_b

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

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

print(sum(l[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():

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

    print(sum(L[:K]))

resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    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]))


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:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n, k = MAP()
l = LIST()
l.sort(reverse=True)
print(sum(l[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7



def main():
  n,k = map(int,input().split())
  l = list(map(int,input().split()))
  
  l = sorted(l,reverse=True)
  
  print(sum(l[:k]))
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n,k=list(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=sum(l[:K])

print(ans)

Submission status: Accepted

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

ls = sorted(ls,reverse=True)
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[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(sum(li[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

l.sort(reverse = True)
ans = []
for i in range(k):
  ans.append(l[i])
  
print(sum(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=[int(x) for x in input().split()]
l=[int(x) for x in input().split()]

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

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
ans = 0
n,k = iim()
L = sorted(iil(),reverse=True)
for i in range(k):
    ans += L[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(l_list[:k]))

Submission status: Accepted

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

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

t.sort(reverse=True)

ans = 0

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

Submission status: Accepted

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

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()))
L.sort(reverse=True)
ans = sum(L[:k])
print(ans)

Submission status: Accepted

Solution code:
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=map(int,input().split())
ls=list(map(int,input().split()))
a=1
ans=0

for i in range(k):
  ans+=sorted(ls)[-a]
  a+=1
  
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:
#ABC067.B
N,K = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
L = l[(N-K):]
ans = sum(L)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(K):
  max += L[i]
  
print(max)

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

Submission status: Accepted

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

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

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
l = na()

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

Submission status: Accepted

Solution code:
# デバッグ用
GBN_DEBUG = False
GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)

#本体ここから

#S = input()
#N = int(input())
#S, T = input().split()
N, K = map(int, input().split())
#W = [input() for _ in range(N)]
l = list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem B - Snake Toy

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

# initialization
l_list = sorted(l_list, reverse=True)
max_len = sum(l_list[:K])

# output
print(max_len)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
l = [int(item) for item in input().split()]
l.sort(reverse=True)
ans = sum(l[:k])
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(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)
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:
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort(reverse=True)
    print(sum(A[:K]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n, k = MAP()
l = LIST()
l.sort(reverse=True)
print(sum(l[:k]))

Submission status: Accepted

Solution code:
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

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

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