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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
lst = sorted(list(map(int, input().split())))
print(sum(lst[: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:
prices = []
total_fruits = 0
max_numb = 0

total_fruits, max_numb = input().split(' ')
tmp_prices = input().split(' ')
tmp_prices = [int(i) for i in tmp_prices]
tmp_prices.sort()
ans = 0
for i in range(int(max_numb)):
  ans += int(tmp_prices[i])
  
print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
para_line = list(map(int,input().split(' ')))
input_line = list(map(int,input().split(' ')))
input_line.sort()
print(sum(input_line[:para_line[1]]))

Submission status: Accepted

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

array.sort()

suma=0
for i in range(K):
  suma=suma+array[i]
print(suma)

Submission status: Accepted

Solution code:
N , K = map ( int , input().strip().split(" ") ) ;
arr = list ( map ( int , input().strip().split(" ") ) ) ; 
arr.sort() ;

print ( sum( arr[:K] ) );

Submission status: Accepted

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

p.sort()
p2 = []
for k in range(0,K):
    p2.append(p[k])

print(sum(p2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
li = [int(i) for i in input().split()]
total = 0
 
for _ in range(K):
	total += min(li)
	li.remove(min(li))
 
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

n = sorted(n)
sum = 0

for i in range(N):
    sum += n[i]
    if i == K-1:
        print(sum)
        exit()

Submission status: Accepted

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

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

t = 0
for e in range(K):
    t += l[e]

print(t)

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

Submission status: Accepted

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

pd = sorted(p)
total = 0

for i in range(k):
    total += pd[i]

print(total)

Submission status: Accepted

Solution code:
N,K = input().split()
N = int(N)
K = int(K)
p = list(map(int, input().split()))
p.sort()
i = 0
count = 0
while i<K:
  count+=p[i]
  i+=1
print(count)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, k = LI()
    p = LI()
    p.sort()
    print(sum(p[:k]))
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
tmp1 = input()
tmp2 = input()

tmp3 = tmp1.split(" ")
tmp4 = tmp2.split(" ")

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

for i in range(N):
    tmp4[i] = int(tmp4[i])

tmp4.sort()
out = 0

for i in range(K):
    out = out + tmp4[i]

print(out)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    N, K = [int(x) for x in input().split()]
    p = sorted([int(x) for x in input().split()])
    print(sum(p[:K]))
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
p = list(map(int, input().split()))
# pのうち、小さい方から順にK個足していく
# pを小さい順に並べる
newlist = sorted(p)
# print(newlist)
# K個足していく
ans = 0
for i in range(K):
  # print(newlist[i])
  ans += newlist[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()
sum = 0
for a in range(k):
	sum+=p[a]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(P[:K]))

Submission status: Accepted

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

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

x.sort()

i=0
S=0

while i<k:
    S+=x[i]
    i+=1

print(S)

Submission status: Accepted

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

def calc_minmum_money(money_list, K):
    money_list.sort()
    minmum_money_list = money_list[:K]
    return sum(minmum_money_list)

print(calc_minmum_money(money_list, K))

Submission status: Accepted

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

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

Submission status: Accepted

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

value = sorted(value)
#print(value)

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

Submission status: Accepted

Solution code:
# 高い物から足していく
def is_possible(arr_sorted, k, money):
  sum = 0
  for i in range(k):
    sum += arr_sorted[i]
    if sum > money:
      return False   
  return True

N, K  = [int(v) for v in input().split()]
p_arr = [int(v) for v in input().split()]
right = 1000 * 1000
left = 0
p_arr.sort()
while( right -left > 1):
  mid = (left+right) // 2
  if is_possible(p_arr, K, mid):
    right = mid
  else:
    left = mid
print(right)

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

Submission status: Accepted

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

numbers = input().split(" ")
n = int(numbers[0])
k = int(numbers[1])

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

p.sort()

r = 0

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

print(r)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
fluit = list(map(int, input().split()))
#fluit.append(input().split())
#print(fluit)
new_fluit = sorted(fluit)
#print(new_fluit)
sum_fluit = sum(new_fluit[:k])
print(sum_fluit)

Submission status: Accepted

Solution code:
# coding: utf-8
# 日本語を入力できるようにするために上記一文が必要


x, y = map(int, input().split() )
num_list = list(map(int, input().split() ) )

num_list.sort()

ans = 0
for i in range(y):
        ans += num_list[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 = list(map(int, input().split()))
  P = list(map(int, input().split()))

  P.sort()

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


if __name__ == "__main__":
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = [int(x) for x in input().split()]
cs = [int(x) for x in input().split()]
cs.sort()

print(sum(cs[:b]))

Submission status: Accepted

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

mix = []
a = 0

while a < k:
    mix.append(min(fruits))
    fruits.remove(min(fruits))
    a += 1

print(sum(mix))

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
l=sorted(list(map(int,input().split())))
ans=0
if k == 1:
    print(l[0])
else:
    print(sum(l[0:k]))

Submission status: Accepted

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

i = 0
total = 0
for i in range(K):
    total = total + fruit_price[i]

print(total)

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    p.sort()
    ans = sum(p[:K])
    print(ans)
if __name__ == "__main__":
    main()

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

Submission status: Accepted

Solution code:
number = input().split()
num = input().split()
num_int = [int(n) for n in num]
number_int = [int(a) for a in number]
num_int.sort()
m = 0
for i in range(number_int[1]):
    m += num_int[i]
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

data = list(int(i) for i in input().split())
s =data.sort()
res = 0
for i in range(k):
    res += int(data[i])
print(res)

Submission status: Accepted

Solution code:
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 998244353

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def to_char(a):
    return chr(a + ord("a"))

def main():
    N, K = read_values()
    P = read_list()
    P.sort()
    print(sum(P[:K]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n, k = nm()
    l = nl()
    print(sum(sorted(l)[:k]))
    return

solve()

Submission status: Accepted

Solution code:
import sys
from numba import njit
from numba import prange

import re

def L(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

def solver(N,K,Pn):
    Pn.sort()

    s = 0
    for i,p in enumerate(Pn):
        s = s + p
        if i == K - 1:
            break

    print(s)

def main():
    N,K = LI()
    Pn = LI()
    #print(N,K,Pn)
    solver(N,K,Pn)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
NK = input()
N, K = int(NK.split(" ")[0]), int(NK.split(" ")[1])

p = input()
lists = []
for i in range(N):
  lists.append(int(p.split(" ")[i]))

lists.sort()

price = 0
for j in range(K):
  price += lists[j]
  
print(price)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

ans = 0

for c1 in range (k):
    ans = ans + ( np.min(p) )
    p.remove(np.min(p))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

q = sorted(p)
SUM = 0

a = 0

for a in range(0, k):
    SUM += q[a]


print(SUM)

Submission status: Accepted

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

sum = 0
min_index = 0

for i in range(k):
    min_index = price_list.index(min(price_list))
    sum += price_list.pop(min_index)

print(sum)

Submission status: Accepted

Solution code:
n,k = [int(x) for x in input().split()]
fs = [int(x) for x in input().split()]
fs_s = sorted(fs)

price = 0

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

print(price)

Submission status: Accepted

Solution code:
import sys

n, k = [int(x) for x in input().strip().split(' ')]
p = [int(x) for x in input().strip().split(' ')]
p.sort()

sum = 0
for i, price in enumerate(p):
    sum += price
    if i >= k-1:
        break

print(sum)

Submission status: Accepted

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

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

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 = input().split(' ')
n = int(n)
k = int(k)
p = input().split(' ')
s =  [int(i) for i in p]
total =0
for _ in range(k):
  total += s.pop(s.index(min(s)))
print(total)

Submission status: Accepted

Solution code:
input_data = [input().split() for l in range(2)]

total_num = int(input_data[0][0])
select_num = int(input_data[0][1])

price_list = []
for price in input_data[1]:
  price_list.append(int(price))

min_price = 0
for p in sorted(price_list)[:select_num]:
  min_price += p

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sorted = sorted(plist)

output = 0
for i in range(k):
  output += sorted[i] 
  
print(output)

Submission status: Accepted

Solution code:
(a,b)=[int(x) for x in input().split()]
cost=[int(x) for x in input().split()]
sum=0
cost=sorted(cost)
for i in range(b):
  sum+=cost[i]
print(sum)

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

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
max_, request = map(int, input().split())
amounts = list(map(int, input().split()))
amounts.sort()
print(sum(amounts[:request]))

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

S = 0
cou = 0
p.sort()

for i in p:
    cou += 1
    S += i
    if cou >= K:
        break
    
print(S)

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

Submission status: Accepted

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

def find_min(lst):
    tmp = lst[0]
    idx = 0
    for i, item in enumerate(lst):
        if item < tmp:
            tmp = item
            idx = i

    return idx


def main():
    n, k = map(int, input().split())
    price = list(map(int, input().split()))

    price_sum = 0

    for i in range(k):
        idx = find_min(price)
        price_sum = price_sum + price.pop(idx)

    print(price_sum)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    answer = solve(N, K, p)
    print(answer)


def solve(N, K, p):
    p.sort(reverse=True)

    sum = 0
    for _ in range(K):
        sum += p.pop()

    return sum


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=(int(x) for x in input().split())
p = [int(a) for a in input().split()]
p.sort()
ans = 0
for t in range(k):
  ans += p[t]

print(ans)

Submission status: Accepted

Solution code:
NK = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
N = NK[0]
K = NK[1]
p.sort()
mix = 0
for i in range(K):
    mix += p[i]
print(mix)

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:
def main():
    _, k = [int(v) for v in input().split(' ')]
    lst_p = [int(v) for v in input().split(' ')]
    lst_p.sort()
    ans = sum(lst_p[:k])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
abc = list(map(int, input().split()))
fgh = sorted(abc)
s = 0
for i in range(b):
  s += fgh[i]
print(s)

Submission status: Accepted

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

p.sort(reverse = False)

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

print(sam)

Submission status: Accepted

Solution code:
s = [input() for i in range(2)] 
li1 = list(map(int, s[0].split()))
li2 = list(map(int, s[1].split()))
N = li1[0]
K = li1[1]

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

Submission status: Accepted

Solution code:
import sys
import math as mt
input=sys.stdin.buffer.readline  
#t=int(input())
t=1
for __ in range(t):
    n,k=map(int,input().split())
    l=list(map(int,input().split()))
    l.sort()
    #s=input()
    print(sum(l[:k]))

Submission status: Accepted

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

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

print(sum(P[:K]))

Submission status: Accepted

Solution code:
def resolve():
    N, K = list(map(int, input().split()))
    p_list = list(map(int, input().split()))
    sorted_p_list = sorted(p_list)
    target_fruits = sorted_p_list[0:K]
    print(sum(target_fruits))

resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

l_1 = input()
l_2 = input()

a, b = l_1.split()
prices = list(map(int, l_2.split()))
prices.sort()

r = 0
for i in range(int(b)):
    r += prices[i]

print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
print(sum(li[0: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:
init = input().split()
N = int(init[0])
K = int(init[1])
 
prices = list(map(int, input().split()))
prices.sort()
 
sum = 0
for i, ele in enumerate(prices):
  if i >= K:
    break
  else:
  	sum = sum + ele
print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

re = 0

l.sort()

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

print(re)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

# print(p)


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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
#n種類からk種類買う
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=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=map(int,input().split())
a = list(map(int,input().split()))

a.sort()

cnt =0
for i in range(k):
    cnt+=a[i]

print(cnt)

Submission status: Accepted

Solution code:
s = input().split()
intN = int(s[0])
intK = int(s[1])

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

#print(inList)
inList.sort()

#print(inList)

idx = 0
intCnt = 0

for wInt in inList:
    if (idx < intK) :
        intCnt += wInt
        #print(wInt) 
        #print(intCnt) 
    idx += 1

print(intCnt)

Submission status: Accepted

Solution code:
N, K=map(int,input().split())
A=map(int,input().split())
AA=list(A)
list.sort(AA,reverse=False)
ans=int(0)
for i in range(K):
    ans += AA[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 = ans + p[i]

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = input().split()
L = [int(b.strip()) for b in A] 
la = sorted(L)[:K]
print(sum(la))

Submission status: Accepted

Solution code:
from sys import stdin, stdout
for _ in range(1):#int(stdin.readline())
    n,k=map(int, stdin.readline().split())
    a=sorted(map(int, stdin.readline().split()))
    print(sum(a[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, K = list(map(int, input().split()))
    P = list(map(int, input().split()))
    result = solve(N, K, P)
    print(result)


def solve(N, K, P) -> int:
    sorted_p = sorted(P)
    return 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()))

new = sorted(p)
num = 0
for i in range(K):
  num += new[i]
print(num)

Submission status: Accepted

Solution code:
temparr = input()
temparr = temparr.split()
n = int(temparr[0])
items = int(temparr[1])
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i))
arr = sorted(arr)
total = 0 
items -= 1 
for i,j in enumerate(arr):
    total += j
    if i == items:
        break
print(total)

Submission status: Accepted

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

fruit_prices.sort()

min_price = 0

for i in range(K):
  min_price += fruit_prices[i]

print(min_price)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
q=[0]*n
r=0
for i in range(n):
    t=0
    for j in range(n):
        if p[i]>p[j]:
            t+=1
    q[t]=p[i]
for i in range(n):
    if q[i]==0:
        q[i]=q[i-1]
for i in range(k):
    r+=q[i]
print(r)

Submission status: Accepted

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

main()

Submission status: Accepted

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

p.sort()
p_sum = 0

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

print(p_sum)

Submission status: Accepted

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

li=sorted(li)
Li=li[0:K]
print(sum(Li))

Submission status: Accepted

Solution code:
syurui,num = map(int,input().split())
hako = []
ans = 0

a = list(map(int,input().split()))
b = sorted(a)

for i in range(num):
    ans = ans + b[i]
print(ans)

Submission status: Accepted

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

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

newH = sorted(H)
print(sum(newH[0:K]))

Submission status: Accepted

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