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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

li = sorted(li)

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

print(ans)

Submission status: Accepted

Solution code:
def main():
	n, k = map(int, input().split())
	P = list(map(int, input().split()))
	sorted_p = sorted(P)
	ans = sum(sorted_p[:k])
	print(ans)
	return

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:

def resolve():
  N, K = map(int, input().split(" "))
  p = [int(x) for x in input().split(" ")]
  p.sort()

  print(sum(p[:K]))

if __name__ == "__main__":
  resolve()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N,K = list(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()))
new = sorted(p)
sum = 0
for i in range(K):
  sum += new[i]
print(sum)

Submission status: Accepted

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

ans=0

p.sort()

for i,j in enumerate(p):
  ans+=j
  if i+1==K:
    break
    
print(ans)

Submission status: Accepted

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

P1 = sorted(P)
P2 = P1[:K]
print(sum(P2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
a = 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)

num=0
for i in range(K):
    num+=P[i]

print(num)

Submission status: Accepted

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

if n == 1:
    print(fruits[0])
else:
    fruits.sort()
    print(sum(fruits[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
[N, K]=list(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())
p = list(map(int, input().split()))

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

Submission status: Accepted

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

fruit = 0
for i in range(nk[1]):
    fruit += p[i]

print(fruit)

Submission status: Accepted

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

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

print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import math
N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(sum(p[0:K]))

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
a = []
for i in range(b):
  a.append(p[i])
  
print(sum(a))

Submission status: Accepted

Solution code:
import sys

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

ans = 0
for i, p in enumerate(sorted(P)):
    if i == K:
        break
    ans += p

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 = list(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=list(map(int,input().split()))
b_list=sorted(a_list)
ans=0
for i in range(K):
    ans+=b_list[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 p[:K]:
  ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

p_list = [int(i) for i in input().split()]

p_list.sort()

# print(p_list)

# print(p_list[:k])
print(sum(p_list[:k]))

Submission status: Accepted

Solution code:
import math
import sys

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

A_sort = sorted(A)

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

print(ans)

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:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
price_list = list(map(int, input().split()))

price_list.sort()

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

print(sum)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
p = list(map(int,input().split()))
cnt = 0
ans = 0
for e in sorted(p):
  ans += e
  cnt += 1
  if cnt==k:
    break
print(ans)

Submission status: Accepted

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

p = sorted(p)
ans = 0

for a in p[:K]:
    ans += a
    #print(a)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

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

Submission status: Accepted

Solution code:

n, k = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]

ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, 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 = sorted(p)
p = p[:k]
ans = sum(p)
print(ans)

Submission status: Accepted

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

ps = sorted(p)

ans = 0

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

Submission status: Accepted

Solution code:
x=input()
x0=x.split()
n=int(x0[0])
k=int(x0[1])
p=input()
p0=p.split()
pl=[int(n) for n in p0]
pl.sort()
print(sum(pl[:k]))

Submission status: Accepted

Solution code:
import sys

(n, k) = map(int, sys.stdin.readline().strip().split())
list_input = list(map(int, sys.stdin.readline().split()))

list_input.sort()

print(sum(list_input[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

p = sorted(p)

print(sum(p[:k]))

Submission status: Accepted

Solution code:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,K = map(int, readline().split())
A = list(map(int,readline().split()))
B =sorted(A)
print(sum(B[:K]))

Submission status: Accepted

Solution code:
import numpy as np


if __name__ == "__main__":
    n, k = map(int, input().strip().split())
    p = list(map(int, input().strip().split()))
    p.sort()

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

Submission status: Accepted

Solution code:
N, K = (int(s) for s in input().rstrip().split())
nums = [int(s) for s in input().rstrip().split()]
sorted_nums = sorted(nums)
print(sum(sorted_nums[:K]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
N, K = map(int,input().split())
p = list(map(int,input().split()))

p.sort()
#print(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()
ans=0
for i in range(k):
    ans+=p[i]
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
L = list(map(int, input().split()))
Ans=0
for i in range(K):
    Ans +=  min(L)
    L.pop(L.index(min(L)))
print(Ans)

Submission status: Accepted

Solution code:
import sys
#sys.exit()
#sorted( ,reverse=True)
#N = int(input())
N, K = map(int, input().split())
P = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]

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

#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
print(ans)

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

Submission status: Accepted

Solution code:
n,k,*l=map(int,open(0).read().split())
print(sum(sorted(l)[:k]))

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
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())
ps=list(map(int,input().split()))
ps.sort()

print(sum(ps[:k]))

Submission status: Accepted

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

a = list(map(int,input().split()))
heapq.heapify(a)
S = 0
for i in range(K):
    mina = heapq.heappop(a)
    S += mina
print(S)

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, k = MI()
    p = sorted(LI())[0:k]
    print(sum(p))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()

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

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

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

X = 0
for i in range(K):
    index = np.argmin(P)
    X += P[index]
    P[index] = 10000
print(X)

Submission status: Accepted

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

a=sorted(a)
ans=0

for b in range(k):
  ans+=a[b]
  
print(ans)

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

lst.sort()

ans = sum(lst[0:k])

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
ps = list(map(int, input().split()))
newlist = sorted(ps)
ans=0
i=0
for p in newlist:
    ans+=p
    if k-1==i:
        break
    i+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

price_list.sort()

print(sum(price_list[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(price[0: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:
[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 = map(int, input().split())

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, K: int, p: "List[int]"):
    pp = sorted(p)
    ans = sum(pp[:K])
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(money)

Submission status: Accepted

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

l_sort = l.sort()

ans = sum(l[:m])

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

p = sorted(p)

s = 0
for i in p[:k]:
    s += i

print(s)

Submission status: Accepted

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

P.sort()
tgt_P = P[:K]

print(sum(tgt_P))

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

ps = sorted(p)

print(sum(ps[: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()))
print(sum([a for a in p[:K]]))

Submission status: Accepted

Solution code:
def main():
    N,K = map(int,input().split())
    p = [0] * N
    p = list(map(int,input().split()))
    p.sort()
    ANS = 0
    for i in range(K):
        ANS += p[i]
    print(ANS)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

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

p.sort()

p_array = np.array(p)
ans_list = p_array[:K]
ans = ans_list.sum()

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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


if 'unittest' not in globals():
    resolve()

Submission status: Accepted

Solution code:
def solve():
	N, K = map(int, input().split())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 0
	for i in range(min(N, K)):
		ans += arr[i]
	return ans

def main():
	# for _ in range(int(input())):
	print(solve())


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
import numpy as np

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n,k=get_ints()
c=get_array()
a=sorted(c)
b=a[:k]
print(sum(b))

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

Submission status: Accepted

Solution code:
from sys import stdin

def main():

    input = stdin.readline

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

    ans = sum(P[0:K])

    print(ans)


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

Submission status: Accepted

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

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

readline = sys.stdin.readline

n, k = map(int, input().split())
p = np.array(readline().split(), dtype=np.int64)
p.sort()
ans = np.sum(p[:k])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

li.sort()

ans = 0

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

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

Submission status: Accepted

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    p = sorted(p)
    p = p[:K]

    res = sum(p)

    print(res)



main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k =map(int, input().split())  #複数数値入力
list_p=list(map(int, input().split()))  #リスト入力

list_p.sort()

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

ps = sorted(p)

ans=0

for i in range(K):
  ans +=ps[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:
n,k = map(int,input().split())
a = [i for i in map(int,input().split())]
a = sorted(a)
print(sum(a[: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(" ")))
pa = sorted(p)

print(sum(pa[:K]))

Submission status: Accepted

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

ans = 0
for p in P[:k]:
    ans += p

print(ans)

Submission status: Accepted

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

print(sums)

Submission status: Accepted

Solution code:
__DEUBG__ = 0

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

if __DEUBG__:
    print(N, K)
    print(prices)

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

Submission status: Accepted

Solution code:
s = str(input())
d = s.split()
n = int(d[0])
k = int(d[1]) 
ps = str(input())
p = ps.split()
l = []
ans = 0
for i in p:
	i = int(i)
	l += [i]
l.sort()
for j in l[0:k]:
	ans += j
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import sys 
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
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(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())
arr=list(map(int,input().split()))
arr.sort()
print(sum(arr[:min(n,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:
import sys

input = sys.stdin.readline

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()))
p2=sorted(p)
ans=sum(p2[0:k])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s,t=map(int,input().split())
lst=list(map(int,input().split()))

lis=sorted(lst)



count=0
for j in range(t):
  count+=lis[j]
  
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 = ans + p[i]

print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
p = [0] * N
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 main():
    n, k = list(map(int, input().split()))
    p_list = list(map(int, input().split()))

    p_list.sort()

    print(sum(p_list[:k]))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    N, K = [int(i) for i in input().split(" ")]
    p = [int(i) for i in input().split(" ")]
    p = sorted(p)
    print(f"{sum(p[:K])}")


if __name__=="__main__":
    main()

Submission status: Accepted

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

print(sum(p_list[:k]))

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.sort()
sum = 0
for i in range(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())))
target = p[0:K]

print(sum(target))

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)