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

Submission status: Accepted

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

l_k=l[:k]

print(sum(l_k))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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)

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

snake = []
for i in range(K):
  value = max(l_list)
  l_list.remove(value)
  snake.append(value)

print(sum(snake))

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

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

Submission status: Accepted

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

for i in range(int(K)):
	length += int(Int[i])
print(length)

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(result))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ls.sort()
print(sum(ls[-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]
else:
    print(ans)

Submission status: Accepted

Solution code:


def main():
    n, k = map(int, input().split())
    data = list(map(int, input().split()))
    data.sort(reverse=True)

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




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data)
print(sum(data[-K:]))

Submission status: Accepted

Solution code:
# num = int(input())
# h, w = list(map(int, input().split()))
# arr = list(map(int, input().split()))

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

new_list_reverse = sorted(org_list, reverse=True)

print(sum(new_list_reverse[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N, K = [int(ele) for ele in input().split()]
l = [int(ele) for ele in input().split()]


def main():
    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())
dat_l = list(map(int, input().split()))
dat_l.sort()
dat_l = dat_l[::-1]
print(sum(dat_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:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, l: "List[int]"):
    l.sort(reverse=True)
    ret = sum(l[:K])
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    l = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, l)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N, K = map(int, input().split())
num_list = [int(i) for i in input().split()]
rev_list = sorted(num_list, reverse = True)
total = 0

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

Submission status: Accepted

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


abc()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

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

sys.setrecursionlimit(2147483647)
INF = float("inf")


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

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

Submission status: Accepted

Solution code:
input1 = input().split(" ")

N = int(input1[0])
K = int(input1[1])

list = input().split(" ")
num_list = []

for num in list:
    num_list.append(int(num))

num_list.sort(reverse=True)

length = 0
for k in range(K):
    length += num_list[k]
    
print(length)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

nums=sorted(nums,reverse=True)
#print(nums)

print(sum(nums[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, raw_input().split())
l_arr = map(int, raw_input().split())

l_arr_sorted = sorted(l_arr, reverse=True)
max_len = 0
for idx in range(0, K):
  max_len += l_arr_sorted[idx]

print(max_len)

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

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    comb = []
    for l in L:
        if len(comb) < K:        
            comb.append(l)
        elif l > min(comb):
            comb[comb.index(min(comb))] = l
    print(sum(comb))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

answer = sum(A[-k:])
print(answer)

Submission status: Accepted

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

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(k):
  s += l[i]
print(s)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nk = list(map(int,input().split(' ')))
nagasa = list(map(int,input().split(' ')))
#print(nagasa)
nagasa.sort(reverse=True)
#print(nagasa)
print((sum(nagasa[:nk[1]])))

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
l.reverse()
i = 0
num = 0
while i < k:
  num += l[i]
  i += 1
print(num)

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

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)

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=[]
for i in range(k):
    a=max(l)
    ans.append(a)
    l.remove(a)
print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

print(A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
c = map(int,input().split())
sList = sorted(c,reverse = True)
sum = 0

for i in range(b):
	sum = sum + sList[i]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce


n, k = map(lambda x: int(x), input().split(' '))
l = list(map(lambda x: int(x), input().split(' ')))

def add_num(a, b):
    return int(a) + int(b)

k *= -1
l.sort()
print(reduce(add_num, l[k:]))

Submission status: Accepted

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

Submission status: Accepted

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

l.sort(reverse=True)

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

print(ans)

Submission status: Accepted

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

sort_l = sorted(l, reverse=True)

cnt = 0
sum = 0
while cnt < K:
    sum += sort_l[cnt]
    cnt += 1
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def solve():
    N, K = list(map(int, input().split()))
    L = list(map(int, input().split()))
    L.sort(reverse=True)

    # 長いものからK本選べばよい
    ans = sum(L[0:K])
    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

print(sum(i[:k]))

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

l.sort()
l.reverse()

# K個の和を出力
print(sum(l[:K]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
lst.sort(reverse=True)
print(sum(lst[0:K]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import itertools
from collections import Counter
from collections import defaultdict
import bisect

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(sum(l[:b]))

Submission status: Accepted

Solution code:
#ABC067B
N, K = map(int, input().split())
ln = list(map(int, input().split()))
ln.sort()
ans = sum(ln[N-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:
m=lambda:map(int,input().split())
N,K=m()
print(sum(sorted(m())[-K:]))

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=[int(x) for x in input().split()]
l.sort()
l = l[::-1]
print(sum(l[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:


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

ln = sorted(ln, key=lambda x:-x)
print(sum(ln[: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:
# ABC067B - Snake Toy
n, k = list(map(int, input().rstrip().split()))
lst = sorted(list(map(int, input().rstrip().split())))
print(sum(lst[n - k:]))

Submission status: Accepted

Solution code:
import sys
from collections import Counter

n, k = map(int, input().split())
l_array = sorted(list(map(int, input().split())), reverse=True)

print(sum(l_array[:k]))

Submission status: Accepted

Solution code:

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

    return n, k, llist

def submit():
    n, k, llist = read_input()
    llist.sort()
    print(sum(llist[-k:]))



if __name__ == '__main__':
    submit()

Submission status: Accepted

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

Submission status: Accepted

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

L.sort()
print(sum(L[N-K:N]))

Submission status: Accepted

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

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:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n, k =f()
    l = f()

    l = sorted(l, reverse = True)

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


solve()

Submission status: Accepted

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

ret = 0
for i in range(k):
    item = max(l)
    max_id = l.index(item)
    l[max_id] = -1
    ret += item
print(ret)

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

l.sort(reverse=1)

print(sum(l[:K]))

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math


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] = list(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:
n,k,*l=map(int,open(0).read().split());print(sum(sorted(l)[::-1][: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 = list(map(int, input().split()))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,K = (int(_) for _ in input().split())
    l = list(int(_) for _ in input().split())
    l.sort()
    l=l[::-1]
    sum_l = 0
    for i in range(0,K):
        sum_l += l[i]
    print(sum_l)
    
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)
x=0
for i in range(k):
    x=x+l[i]

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n, k = [int(i) for i in input().split()]
    ls = [int(i) for i in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(l[:k]))

Submission status: Accepted

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

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

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

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