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 = map(int,input().split())
P = sorted(map(int,input().split()))
result = 0
for i in range(K):
	result += P[i]
print(result)

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 numpy as np

N, K = map(int, input().split())
p = [int(x) for x in input().split()]

p_sorted = np.sort(p)
sum_min = np.sum(p_sorted[0:K])

print(sum_min)

Submission status: Accepted

Solution code:
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():

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

    p.sort()
    result = 0
    for i in range(k):
        result += p[i]
    print(result)



if __name__ == '__main__':
    main()

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 = sorted(p)
x = sum(p[: K])
print(x)

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

p.sort()
list = []

for i in range(k):
    list.append(p[i])
    
print(sum(list))

Submission status: Accepted

Solution code:
def main():
    entrada = list(map(int, input().split()))
    frutas = list(map(int, input().split()))
    frutas.sort()
    suma = 0
    for i in range(entrada[1]):
        suma = suma + frutas[i]

    print(suma)


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 = [int(i) for i in input().split()]
p.sort()
ans = sum(p[0:k])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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()))
p.sort()
print(sum(p[:K]))

Submission status: Accepted

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

print(n)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k = LI()
    a = sorted(LI())

    return sum(a[:k])


print(main())

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count=0
p.sort()
for i in range(k):
  count+=p[i]
  
print(count)

Submission status: Accepted

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

sp = sorted(p)
print(sum(sp[:K]))

Submission status: Accepted

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

m = []
for i in range(K):
    a = min(p)
    m.append(a)
    p.remove(a)

print(sum(m))

Submission status: Accepted

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

p_min = []
for i in range(k):
    a = min(p)
    p_min.append(a)
    p.remove(a)

print(sum(p_min))

Submission status: Accepted

Solution code:
a,b= input().split(" ")
list1 = input()
x = [int(i) for i in list1.split()]
x = sorted(x)
sum = 0
for i in range(int(b)):
    
    sum += x[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:
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=sorted(list(map(int,input().split())))
print(sum(l[0:k]))

Submission status: Accepted

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


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

p.sort()

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

Submission status: Accepted

Solution code:
n, k = input().split(" ")
n = int(n)
k = int(k)
a = [int(x) for x in input().split(" ")]
a.sort()
ans = 0
for i in range(k):
 ans += int(a[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:
def main():
    n,k = map(int,input().split())
    p = [int(i) for i in input().split()]
    p.sort()
    print(sum(p[:k]))
main()

Submission status: Accepted

Solution code:
A,B = map(int,input().split())
L = list(map(int,input().split()))
L.sort()
print(sum(L[:B]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
P = [int(p) for p in input().split()]
ans = 0

for i in range(K):
  ans += min(P)
  P.remove(min(P))

print(ans)

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

p.sort()

ans = 0
for i in range(k):
  ans += p.pop(0)
  
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:
a = input().split()
# a[0] is N個
# a[1] is K個
b = list(map(int, input().split()))
b.sort()

sum = 0

for i in range(int(a[1])):
    sum += b[i]

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()
print (sum([p[i] for i in range(k)]))

Submission status: Accepted

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

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 = sorted(p)
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()))
p.sort()
p1=p[:k]
print(sum(p1))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(0, K):
    s += q[i]

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import 
#=input()
#=int(input())
n,k=map(int,input().split())
p=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

p.sort()
s = 0
for i in range(k):
    s += p[i]
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

t = sorted(p,reverse = False)

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

Submission status: Accepted

Solution code:

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


submit()

Submission status: Accepted

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

Submission status: Accepted

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

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:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

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

Submission status: Accepted

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

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

ld = sorted(fruits)[:K]

print(sum(ld))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

prices.sort()

purchase_price = sum(prices[0:k])

print(purchase_price)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
list = [int(i) for i in input().split()]
list_sorted = sorted(list)
money=0
count=0

for j in range(1,K+1):
    money+=list_sorted[count]
    count+=1

print(money)

Submission status: Accepted

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

for i in range(len(p)):
    for j in reversed(range(i+1,len(p))):
        if p[j] < p[j-1]:
            p[j-1],p[j] = p[j],p[j-1]

print(sum(p[:k]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,k=map(int,input().split())
pricelist=list(map(int,input().split()))
pricelist.sort()
sumprice=0
for i in range(k):
  sumprice+=pricelist[i]
print(sumprice)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:
number = input().split(" ")
N = int(number[0])
K = int(number[1])
 
list = []
numbers = input().split(" ")
for i in numbers:
    list.append(int(i))
list.sort()
 
a = 0
 
for i in range(K):
	a += int(list[i])
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

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

p.sort()

for i in range(K):
  l.append(p[i])
print(sum(l))

Submission status: Accepted

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

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

pa = sorted(p)

print(sum(pa[:k]))

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
fruit = list(map(int, input().split()))
fruit2 = sorted(fruit,reverse=False)
sum = 0
for item in fruit2[0:b]:
	sum = sum + item

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range

def main():
  n,k = map(int,read().split())
  a = sorted(list(map(int,read().split())))
  write('{}\n'.format(sum(a[:k])))

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range

def main():
	n,k = map(int,read().split())
	a = sorted(list(map(int,read().split())))
	write('{}\n'.format(sum(a[:k])))

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
from sys import stdin, stdout
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = range

def main():
	n,k = map(int,read().split())
	a = list(map(int,read().split()))
	a.sort()
	write('{}\n'.format(sum(a[:k])))

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
values = [int(value) for value in input().split()]
values.sort()
ans = sum(values[:K])
print(ans)

Submission status: Accepted

Solution code:
line = [input() for i in range(2)]

status = [int(x) for x in line[0].split()]
fruits = [int(x) for x in line[1].split()]

status
fruits = sorted(fruits)

i = 1
total = 0
for fruit in fruits:
    i += 1
    total += int(fruit)
    if int(status[1]) < i:
        break
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
import numpy as np
P = [int(i) for i in input().split()]
P.sort()
P = np.array(P)
print(P[:k].sum())

Submission status: Accepted

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

plist.sort()
ans = 0
for i in range(k):
    ans += plist[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:
import numpy as np

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

p = np.array(p)
p = np.sort(p)

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

price2 = sorted(price)
i = 0
sum = 0
while (i < K):
  sum += price2[i]
  i += 1

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

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 += p[i]

print(ans)

Submission status: Accepted

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

print(sum(ps[:k]))

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
p = list(map(int, input().split()))
new_p = sorted(p)
numbers = []
for i in range(K):
    numbers.append(new_p[i])
print(sum(numbers))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k,*l=map(int,open(0).read().split());l.sort();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,k = map(int,input().split())

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

soma = 0

lista.sort()

for i in range(k):
    soma += lista[i]

print(soma)

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

Submission status: Accepted

Solution code:
import numpy as np

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

p.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()
s = 0
for i in p[:k]:
  s += i
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

a=sorted(a)

print(sum(a[: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:
a,b = map(int,input().split())
price = [int(s) for s in input().split()]
pric = sorted(price)
sum = 0
for i in range(b):
    sum += int(pric[i])
print(sum)

Submission status: Accepted

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

# check
print(sum(p[: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.sort()

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

Submission status: Accepted

Solution code:
a,b = map(int, input().split()) #a,bに[5 3]みたいな入力を格納できる
cost = sorted(map(int, input().split())) # 入力をソート

ans = 0

for i in range(0, b):
  ans = ans + cost[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def solve():
    N, K = list(map(int, input().split()))
    Ps = list(map(int, input().split()))
    Ps.sort()
    ans = sum(Ps[0:K])
    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.

Author : Takeshi Saga

"""

import itertools
import numpy as np

tmp = input()
#tmp = "5 3"
N,K = tmp.split()
que = input()
#que = "50 100 80 120 80"
try:
    N = int(N)
except:
    pass
try:
    K = int(K)
except:
    pass



que = [int(x) for x in que.split()]

#print(que)
"""
tmp = []
for x in que:
    for xx in range(K):
        tmp.append(x)
que = tmp
"""
min_val = 999999999

que = sorted(que)

#for x in itertools.combinations(que, K):

x = [que[i] for i in range(K)]
min_val = np.sum(x)

print(min_val)

Submission status: Accepted

Solution code:
from sys import stdin

N,K = (int(x) for x in stdin.readline().rstrip().split())

plist = [int (x) for x in stdin.readline().rstrip().split()]

plist.sort()

print(sum(plist[:K]))

Submission status: Accepted

Solution code:
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,K = LI()
p = sorted(LI())
print(sum(p[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=input().split() # 5 3
n=int(n)
k=int(k)
kudamono=list(map(int,input().split()))# [50, 100, 80, 120, 80]
kudamono.sort()

print(sum(kudamono[:k]))

Submission status: Accepted

Solution code:
import sys

input_data = []
input_pointer = 0

output_data = []

def input_scan():
    global input_data
    input_data = sys.stdin.readlines()
    input_data = [x[:-1] for x in input_data]

def next_line():
    global input_pointer
    global input_data
    if input_pointer < len(input_data):
        input_pointer += 1
        return input_data[input_pointer - 1]
    else:
        return ""

def append_output(string):
    global output_data
    output_data.append(string)

def print_output():
    global output_data
    output_data.append("")
    sys.stdout.write("\n".join(output_data))

# Problem A
# alpha = input()
# if alpha.isupper():
#     print("A")
# else:
#     print("a")

# Problem B
input_scan()
[n, k] = [int(x) for x in next_line().split(" ")]
fruits = sorted([int(x) for x in next_line().split(" ")])
print(sum(fruits[:k]))

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

Submission status: Accepted

Solution code:
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict


n,k=MAP()
a=sorted(LI())
print(sum(a[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()
a = a.split()
b = input()
b = b.split()

for i in range(len(a)):
    a[i] = int(a[i])

for i in range(len(b)):
    b[i] = int(b[i])
    
b.sort()
c = 0


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

print(c)

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(K):
    amount = amount + sortPrice[i]

print(amount)

Submission status: Accepted

Solution code:
a = input().split(' ')
n, k = a
n, k = int(n), int(k)
ps = input().split(' ')
pf = []
for i in ps:
    t = int(i)
    pf.append(t)
pf = sorted(pf)
c = []
s = 0

for i in range(k):
    for j in range(n):
        if j in c:
            continue
        c.append(j)
        s += pf[j]
        break

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#create date: 2020-06-29 09:33

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, k = na()
    p = na()
    p.sort()
    print(sum(p[:k]))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from functools import reduce

def main(n, k, p):
    """ main
    """
    p.sort()
    return sum(p[0:k])

if __name__ == "__main__":
    N, K = map(int, sys.stdin.readline().split(" "))
    P = list(map(int, sys.stdin.readline().split(" ")))

    print(main(N, K, P))

Submission status: Accepted

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

Submission status: Accepted

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

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

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