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

if __name__ == '__main__':
    b, c = map(int, input().split())
    a = [int(i) for i in input().split()]

    a.sort(reverse=True)
    count = 0
    for i in range(c):
        count+=a[i]
    print(count)

Submission status: Accepted

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

l = sorted(l)[::-1]
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:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

A.sort(reverse=True)

print(sum(A[:K]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
L = [int(l) for l 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(key=lambda x: -x)
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:
a, b = map(int, input().split())
length = map(int, input().split())
length = sorted(length, reverse=True)

print(sum(length[:b]))

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

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

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

l.sort(reverse=True)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

als = sorted(al)
rl = als[n-k:]
print(sum(rl))

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

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

print(sum(l[:K]))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

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

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

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


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

    N, K = il()
    L = sorted(il(), 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()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

L = sorted(L, reverse=True)

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

print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

#1≤K≤N≤50
#1≤li≤50

l = sorted(l)[-k:]

print(sum(l))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

loops.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,K = inputIL()
l = inputIL()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

Submission status: Accepted

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

    print(sum(sorted(L)[::-1][:k]))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
import string
import collections
from collections import Counter


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, k = map(int, input().split())
l = readints()
ll = sorted(l)
sum = 0
for i in range(k):
    sum += ll[-(i+1)]
print(sum)

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:
import sys
import math
import bisect

def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    print(sum(A[-m:]))

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 = sorted(list(map(int, input().split())))[::-1]
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

l = list(sorted(l, reverse=True))
s = 0
for a in range(0, k):
    s += l[a]

print(s)

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

L2 = sorted(L, reverse = True)

print(sum(L2[:K]))

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(K):
    ma += D[i]

print(ma)

Submission status: Accepted

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

Submission status: Accepted

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

A = list(map(int,input().split()))
A.sort()

tar = A[-K:]
tar_sum = sum(tar)
print(tar_sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

l.sort(reverse=True)
answer = 0

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

print(answer)

Submission status: Accepted

Solution code:
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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


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

Submission status: Accepted

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

l = sorted(l, reverse=True)

print(sum(l[:k]))

Submission status: Accepted

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

l = sorted(l, reverse=True)
score = 0

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

print(score)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

dp = [[-1]*(K + 1) for _ in range(N + 1)]
for j in range(K + 1):
    dp[0][j] = 0

for i in range(N):
    for j in range(K + 1):
        if j >= 1:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - 1] + A[i])
        else:
            dp[i + 1][j] = dp[i][j]
            
print(dp[N][K])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l=sorted(l,reverse=True)
print(sum(l[0: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, log2
from itertools import accumulate, permutations, combinations, product, groupby
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
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 = LIST()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,k=MI()
ls=sorted(LI(),reverse=True)
ans=0
for i in range(k):
    ans+=ls[i]
print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest


def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, k = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    L = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    Lsort = sorted(L, reverse=True)
    re = 0
    for i in range(k):
        re += Lsort[i]

    print(re)
resolve()

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:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))
    l_arr = list(map(int,_in[1].split(' ')))
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    l_arr.sort(reverse=True)
    cnt = sum(l_arr[:K])
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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());print(sum(sorted([int(x) for x in input().split()], reverse=True)[:k]))

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/abc067/tasks/abc067_b
# Python 3rd 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(allNumber, selectNum, eachLength):
    result = 0
    # algorithm
    sortedStickLength = sorted(eachLength, reverse=True)
    #    print("{}:{}".format(sortedStickLength, eachLength))
    for j in range(0, selectNum, +1):
        result = result + sortedStickLength[j]
    return result


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

List = list(map(int,input().split()))
List = sorted(List)
for i in range(N-K):
  del List[0]

print(sum(List))

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:
k=int(input().split()[1])
print(sum(sorted([int(x) for x in input().split()],reverse=1)[: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())
ln = list(map(int, input().split()))
ln.sort(reverse=True)
print(sum(ln[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if '__main__' == __name__:
    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:
N,K = map(int, input().split())
l = list(map(int,input().split()))
l.sort()
lrev = l[::-1]
print(sum(lrev[:K]))

Submission status: Accepted

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

Submission status: Accepted

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