Problem:


Score : 200 points

Problem Statement

A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)

Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.

Constraints

1 \leq K \leq N \leq 1000

1 \leq p_i \leq 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p_1 p_2 \ldots p_N

Output

Print an integer representing the minimum possible total price of fruits.

Sample Input 1

5 3
50 100 80 120 80

Sample Output 1

210

This shop sells Fruit 1, 2, 3, 4, and 5 for 50 yen, 100 yen, 80 yen, 120 yen, and 80 yen, respectively.

The minimum total price for three kinds of fruits is 50 + 80 + 80 = 210 yen when choosing Fruit 1, 3, and 5.

Sample Input 2

1 1
1000

Sample Output 2

1000



Sample input:
5 3
50 100 80 120 80


Sample output:
210

Submission status: Accepted

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

total = 0
for i in range(K):
    total += P.pop()

print (total)

Submission status: Accepted

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

ans = sum(P[:k])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N, K = map(int, sys.stdin.readline().split())
P = list(map(int, sys.stdin.readline().split()))

P.sort()
print(sum(P[0:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,K = MI()
p = LI()
p.sort()
print(sum(p[i] for i in range(K)))

Submission status: Accepted

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

arr.sort()

print(sum(arr[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

pl = list(map(int, input().split()))
pl.sort()
ans = sum(pl[:k])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B
N, K = map(int,input().split())
P = list(map(int, input().split()))
P_sort=sorted(P)
P_sum=0
for i in range(K):
    P_sum+=P_sort[i]
print(P_sum)

Submission status: Accepted

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

a.sort()
ans = 0
for i in range(k):
    ans += a[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

a.sort()
c = 0

for i in range(K):
  c = c + a[i]

print(c)

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
P = list(int(n) for n in input().strip().split())[:N]
P.sort()
total = 0
for i in range(K):
    total +=P[i]
print(total)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

prices.sort()

print(sum(prices[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

pay = 0
for i in range(K):
    pay += sorted(p)[i]

print(pay)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
P.sort()
b=0

for i in range(K):
    b+=P[i]
    
print(b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
k = int(input().split(' ')[1])

n = sorted([int(n) for n in input().split(' ')])

s = sum(n[0:k])

print(s)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


def next_line():
    return input()


def next_int():
    return int(input())


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


def strs():
    return input().split()


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


def int_ar_mul(size):
    return [int(input()) for _ in range(size)]


def str_ar(size):
    return [input() for _ in range(size)]


def main():
    n, k = ints()
    p = sorted(int_ar())
    res = 0
    for i in range(k):
        res += p[i]
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
r=input().split()
N=int(r[0])
K=int(r[1])
d_pre=input().split()
d=[int(s) for s in d_pre]
d.sort()
ans=0
for i in range(K):
    ans+=d[i]
print(ans)

Submission status: Accepted

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

p_sort = p.sort()
p_sort_K = p[0:K]
print(sum(p_sort_K))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

sum = 0

for i in range(K):
    sum += int(p[i])
print(sum)

Submission status: Accepted

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

p.sort()

print(sum(p[:K]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B - Mix Juice
N,K = map(int,input().split())
p = list(map(int,input().split()))
p_sorted = sorted(p,reverse = False)
ans = sum(p_sorted[:K])
print(ans)

Submission status: Accepted

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

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

p.sort()

price=0

for i in range(k):
    price += p[i]
print(price)

Submission status: Accepted

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

p.sort()
#print(p)

sum = 0
for i in range(K):
	sum = sum + p[i]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()
for i in range(k):
    ans += p[i]

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, k = inm()
a = sorted(inl())
print(sum(a[:k]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
p = list(map(int, input().split()))
sortPrice = sorted(p)
# print(sortPrice)
price = []
for i in range(0, k):
    price.append(sortPrice[i])
print(sum(price))

Submission status: Accepted

Solution code:
a, nums = map(int, input().split())
add = 0
lst = list(map(int, input().split()))
lst.sort()
for i in range(0,nums):
  add += lst[i]

print(add)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(K):
    ans += min(lst)
    lst.remove(min(lst))
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    N,K = [int(i) for i in input().split()]
    P = [int(i) for i in input().split()]
    print(sum(sorted(P)[:K]))

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

print(sum(sorted(P)[:K]))

Submission status: Accepted

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

p.sort()
print(sum(p[:K]))

Submission status: Accepted

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

P.sort()
print(sum(P[:K]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
k = int(input().split(' ')[1])
print(sum( sorted([int(n) for n in input().split(' ')])[0:k]))

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline

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


n, k = inlt()
p = inlt()
p = sorted(p)
print(sum(p[:k]))

Submission status: Accepted

Solution code:
n,k = input().split()
k = int(k)-1
a = list()
a = input().split(" ")
b = list()
for i in a:
    b.append(int(i))
b.sort()
sum = 0
while k>=0:
    sum += b[k]
    k -= 1
print(sum)

Submission status: Accepted

Solution code:


# ---------------------------------------MAIN()-----------------------------------------------!
n, k = map(int, input().split(" "))
l = list(map(int, input().split(" ")))
l.sort()
s=0
for i in range(k):
  s+=l[i]
print(s)


# -----------------------------------------------------------------------------------------!

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = input().split(" ")
lst = list(map(int,input().split(" ")))
lst_s = sorted(lst)
res = lst_s[0:int(b)]
print(sum(res))

Submission status: Accepted

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

P.sort()
ans = sum(P[0:K])

print(ans)

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
nums = [int(x) for x in input().split()]
nums = sorted(nums)
sum = 0
for i in range(k):
  sum += nums[i]
print(sum)

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    p_lst = list(map(int, input().split()))
    p_lst.sort()
    minimum = 0
    
    for i in range(k):
        price = p_lst[i]
        minimum += price
        
    print(minimum)
    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

prices.sort()
print(sum(prices[:k]))

Submission status: Accepted

Solution code:

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

p.sort()

print(sum(p[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
P=list(input().split())
Ps=[int(s) for s in P]
Ps.sort()
Psx=Ps[:K]


print(sum(Psx))

Submission status: Accepted

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

P.sort()

print(sum(P[:K]))

Submission status: Accepted

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

p.sort()
print(sum(p[:k]))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, k, *p = map(int, read().split())
    p.sort()
    r = sum(p[:k])
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

min=p[0]
for i in range(n-1) :
    for j in range(n-1-i) :
        if(p[i]>p[j+i+1]) :
            t=p[i]
            p[i]=p[j+i+1]
            p[j+i+1]=t
    
sum=0
for i in range(k) :
    sum+=p[i]

print(sum)

Submission status: Accepted

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

price = input().split(" ")
list1 = []

for j in price:
    list1.append(int(j))

list1 = list1[:int(N)]
list1.sort()

list2 = list1[:int(K)]

summ = 0
for i in list2[:int(K)]:
    summ += int(i)

print(summ)

Submission status: Accepted

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

Submission status: Accepted

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

p = list(map(int,input().split()))
p_sort = sorted(p)

print(sum(p_sort[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

prices.sort()
print(sum(prices[:K]))

Submission status: Accepted

Solution code:
from itertools import product, permutations, combinations
import math
N, K = map(int, input().split())
P = list(sorted((list(map(int, input().split())))))

print(sum([P[i] for i in range(K)]))
exit()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
p = sorted(map(int, input().split()))
i = 0
for j in range(k):
    i = i + p[j]
print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
price_list = [int(x.strip()) for x in input().split()]
sorted_list = sorted(price_list)
ans = sum(sorted_list[:k])
print(ans)

Submission status: Accepted

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

P.sort()
ans = 0
for i in range(K):
  ans += P[i]
print(ans)

Submission status: Accepted

Solution code:
# Mix Juice
N,K = map(int,input().split())
p = sorted(list(map(int, input().split())))
ans = sum(p[:K])
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
P = list(map(int,input().split()))
a = 0
for i in range(K):
  a += min(P)
  del P[P.index(min(P))]
print(a)

Submission status: Accepted

Solution code:
N, K = input().split()
N, K = int(N), int(K)
p = list(map(int, input().split()))
sum = 0
for i in range(K):
  min_price = min(p)
  p.remove(min(p))
  sum+= min_price
print(sum)

Submission status: Accepted

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

p_s = sorted(p)

print(sum(p_s[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()

for i in range(0,K):
  Ans += p[i]

print(Ans)

Submission status: Accepted

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

for i in range(k):
    money += p[i]

print(money)

Submission status: Accepted

Solution code:
NK = input().split()
Pn = input().split()
for i in range(int(NK[0])):
    Pn[i] = int(Pn[i])
Pn.sort()
s = 0
for i in range(int(NK[1])):
    s += Pn[i]
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p = input().split()
p = [int(s) for s in p]
p.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
p_N = [int(i) for i in input().split()]
import heapq
print(sum(heapq.nsmallest(K,p_N)))

Submission status: Accepted

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

price.sort()
sum = 0
for i in range(K):
    sum += price[i]

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
p = list(map(int, input().split()))
a = sorted(p, reverse=False)
c = 0
for b in a[:M]:
  c = c + b
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,k=map(int,input().split())
hako=list(map(int,input().split()))
hako.sort(reverse=True)
fin=0
for i in range(k):
  fin=fin+hako.pop()
print(fin)

Submission status: Accepted

Solution code:
import numpy

N, K = (int(x) for x in input().split())

p = [int(x) for x in input().split()]

p.sort()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K= map(int,input().split())
P = list(map(int,input().split()))
Pnew = sorted(P)
total = 0
for i in range(K):
    total += Pnew[i]

print(str(total))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
nums = sorted(map(int, input().split()))  # 入力のときに N を使う必要はありません
print(sum(nums[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
p = [int(x) for x in input().split()]
a = [0]*k
for i in range(k):
  a[i] = min(p) + a[i-1]
  b = p.index(min(p))
  p[b] = 1001
print(a[k-1])

Submission status: Accepted

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

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

a = p[:K]

print(sum(a))

Submission status: Accepted

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

p.sort()

print(sum(p[:k]))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(SUM)

Submission status: Accepted

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

print(sum(p_list[:K]))

Submission status: Accepted

Solution code:
X,Y = map(int,input().split())
MMM = map (int,input().split())
MM = list(MMM)
MM.sort()
total = 0
for i in range(Y):
  total += MM[i]
print(total)

Submission status: Accepted

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

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

p.sort()

print(sum(p[:k]))

Submission status: Accepted

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

p.sort()
ans = sum(p[0:k])
print(ans)

Submission status: Accepted

Solution code:
NK = list(map(int,input().split()))
prices = list(map(int,input().split()))

prices.sort()
print(sum(prices[:NK[1]]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
p = [int(i) for i in input().split()]
p.sort()
money = 0
for j in range(K):
    money += p[j]
print(money)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
NK = list(map(int, input().split()))
P = list(map(int, input().split()))
sum = 0
P.sort()

for i in range(NK[1]):
  sum+=P[i]

print(sum)

Submission status: Accepted

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

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

P = sorted(p)
price = 0
for i in range(k):
    price += P[i]

print(price)

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[:K]))

Submission status: Accepted

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

t = 0
ss = sorted(s)
for kk in range(k):
    t += ss[kk]
print(t)

Submission status: Accepted

Solution code:
N, K = input().split(sep=' ')
p = list(input().split(sep=' '))
p = list(map(int, p))
p.sort()
buy = 0
for item in range(int(K)):
  buy += p[item]
print(buy)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    Qb()

Submission status: Accepted

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

p_lst = sorted(p_lst)
print(sum(p_lst[:k]))

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split(' ')]
p = [int(i) for i in input().split(' ')]
print(sum(sorted(p)[:K]))

Submission status: Accepted

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

print(sum(p[:K]))

Submission status: Accepted

Solution code:
N = list(map(int, input().split()))
fruits = list(map(int, input().split()))
sum = 0
fruits.sort()

for i in range(N[1]):
    sum +=  fruits[i]
print(sum)

Submission status: Accepted

Solution code:
nk = [int(s) for s in input().split()]
k = nk[1]

p = [int(s) for s in input().split()]

p.sort()
print(sum(p[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
p = [int(s) for s in input().split()]
sum = 0

for i in range(k):
    sum += min(p)
    p.remove(min(p))
print(sum)

Submission status: Accepted

Solution code:
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！

n,k = MI()
li = sorted(LI())
print(sum(li[:k]))

Submission status: Accepted

Solution code:

def main():
    
    kinds = list(map(int,input().split()))
    prices = list(map(int,input().split()))
    
    minPrice = 0
    
    for item in range(kinds[1]):
        minPrice += min(prices)
        prices.remove(min(prices))

    print(minPrice)         
    
  

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

def quickSort(arr):
  if len(set(arr)) == 1:
    return arr
  res = []
  pivot = arr[math.floor(len(arr)/2)]
  left = []
  right = []
  center = []
  for i in arr:
    if i < pivot:
      left.append(i)
    elif i > pivot:
      right.append(i)
    else:
      center.append(i)
  if len(left) != 0:
    res = quickSort(left)
  res.extend(center)
  if len(right) != 0:
    res.extend(quickSort(right))
  return res

p = quickSort(p)
print(sum(p[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

p.sort()

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

print(ans)

Submission status: Accepted

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

a.sort()
print(sum(a[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p = sorted(p)

p = p[:K]

print(sum(p))

Submission status: Accepted

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

p = sorted(p)  # 小さい順
sum = 0

for i in range(k):
    sum += p[i]
print(sum)

Submission status: Accepted

Solution code:
M,N = map(int,input().split(" "))
A = list(map(int,input().rstrip().split(" ")))
a=sorted(A)
ans=0
for i in range(N):
    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)
print(sum(l[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

n,k=input2()
p=input_array()
sp=sorted(p)

print(sum(sp[:k]))