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:
tmp = input().split(" ")
N = int(tmp[0])
K = int(tmp[1])
ary = list(map(lambda x: int(x), input().split(" ")))
ary.sort()

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

Submission status: Accepted

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

p_sort = sorted(p)

p_sum = sum(p_sort[0:k])

print(p_sum)

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()))
print(sum(sorted(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())
p = [int(e) for e in input().split()]

# print(p)
p.sort()
# print(p)

ans = 0
for e in p[:K]:
  ans += e

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a = input().split()

a = list(map(int,a))

a.sort()

b = sum(a[:K])
print(b)

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

Submission status: Accepted

Solution code:
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

n,k = Mi();
p = Li();
p.sort();
print(sum(p[:k]))

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    *P, = map(int, input().split())

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

print(s)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=list(map(int,input().split()))
ans=0
s=sorted(s)
for i in range(b):
  ans+=s[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())
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:
# ABC171
# B Mix Juice
N, K = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
a = 0
for i in range(K):
    a += p[i]
print(a)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = 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 = input("").split()
p = [int(i) for i in p]
p = sorted(p)

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce as R

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def _Ss(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Ss(): return _Ss(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

N, K = I()
xs = sorted(Is())
print(np.sum(xs[:K]))

Submission status: Accepted

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

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

P.sort()

print(sum(P[:K]))

Submission status: Accepted

Solution code:
def main(istr, ostr):
    n, k = list(map(int, istr.readline().strip().split()))
    ls = list(map(int, istr.readline().strip().split()))
    ls.sort()
    result = sum(ls[:k])
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)

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:
num = input().split(" ")
num_all = int(num[0])
count = int(num[1])
cost = list(map(int, input().split()))
cost.sort()
last = 0
for i in range(count):
  last += cost[i]
print(last)

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
from numba import njit
import sys
sys.setrecursionlimit(10**7)

def _S(): 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())

N,K = LI()
p = LI()
p.sort()
p1 = np.array(p)
print(p1[:K].sum())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# input
a, b = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
o = 0
for i in range(b):
    o = o+x[i]
print(o)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int,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=[int(i) for i in input().split()]

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

Submission status: Accepted

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

p = [int(i) for i 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()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

p_list_min = sorted(p_list)
ans = sum(p_list_min[0:k])

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 solve(string):
    n, k, *p = map(int, string.split())
    p = sorted(p)
    return str(sum(p[:k]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

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

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

count = 0
min_price = 0
while count < k:
  #print(count)
  total = min_price
  for i in range(len(lst)):
    total += lst[i]
    #print(total)
    if i == 0:
      min_price = total
      min_index = i
    elif total < min_price:
      min_price = total
      min_index = i
    total -= lst[i]
  lst.pop(min_index)
  count += 1
print(min_price)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

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

ans = p[:K].sum()

print(ans)

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:
a=input()
l=a.split(" ")
n=int(l[0])
k=int(l[1])
f=input()
fruits=f.split(" ")
for d in range(0, len(fruits)):
    fruits[d]=int(fruits[d])
ans=0
b=0
while(b<k):
    g=min(fruits)
    ans+=g
    fruits.remove(g)
    b+=1
print(ans)

Submission status: Accepted

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

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

p.sort()
cost = 0

for k in range(K):
    cost += p[k]
print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(list(dict.fromkeys(ans)))
    if(ans[-1]==n):
        ans = ans[:-1]
    return ans

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

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())
a = list(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()))
sum_price = 0
p.sort()
print(sum(p[0:K]))

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc171/tasks/abc171_b

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

p_list = sorted(p_list)

total_val = 0

for i in range(K):
    total_val += p_list[i]

print(total_val)

Submission status: Accepted

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

p.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = list(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())
lst_p=list()
tot=0

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

def sort(my_list):
    size = len(my_list)
    for i in range(size):
        for j in range(size-i-1):
            if(my_list[j] > my_list[j+1]):
                tmp = my_list[j]
                my_list[j] = my_list[j+1]
                my_list[j+1] = tmp
    return my_list

lst_p = sort(lst_p)

for i in range(k):
    tot += lst_p[i]
print(tot)

Submission status: Accepted

Solution code:
asdfasdfasdf, a = map(int, input().split())
b = list(map(int, input().split()))
d = 0
for c in range(a):
    d += min(b)
    b.remove(min(b))
print(d)

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N,K = inputlist()
p = inputlist()
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())
x=list(map(int,input().split()))
x.sort()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(sum(p[:k]))

Submission status: Accepted

Solution code:
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
n,k = inm()
p = inl()
p = sorted(p)
print(sum(p[: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()
total = 0
for i in range(k):
  	total += p[i]
print(total)

Submission status: Accepted

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

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

Submission status: Accepted

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

s_price=sorted(price)

mysum=0

for i in range(k):
  mysum+=s_price[i]
  
print(mysum)

Submission status: Accepted

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

l_min = sorted(l)

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

Submission status: Accepted

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

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# abc171_b.py
# https://atcoder.jp/contests/abc171/tasks/abc171_b

# B - Mix Juice /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# ある店で N種類の果物、果物 1,…,N が売られており、それぞれの価格は一個あたり p1,…,pN円です。
# この店で K種類の果物を一個ずつ買うとき、それらの合計価格として考えられる最小の金額を求めてください。

# 制約
#     1≤K≤N≤1000
#     1≤pi≤1000
#     入力中の値はすべて整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N K
# p1 p2 … pN

# 出力
# 果物の最小の合計価格を表す整数を出力せよ。

# 入力例 1
# 5 3
# 50 100 80 120 80

# 出力例 1
# 210

# この店では、果物 1,2,3,4,5がそれぞれ 50 円、100 円、80 円、120 円、80円で売られています。
# これらから 3種類を買うときの最小合計価格は、果物 1,3,5 を買うときの 50+80+80=210円です。

# 入力例 2
# 1 1
# 1000

# 出力例 2
# 1000


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    N, K = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    values.sort()
    tmps = values[:K]
    result = sum(tmps)

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['5 3', '50 100 80 120 80']
        lines_export = [210]
    if pattern == 2:
        lines_input = ['1 1', '1000']
        lines_export = [1000]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
A = list(map(int, input().split()))
result = 0
for i in range(N):
    for j in range(i):
        if A[i-j-1] > A[i-j]:
            tmp = A[i-j]
            A[i-j] = A[i-j-1]
            A[i-j-1] = tmp

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

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def bubblesort(l):
    for index in range(len(l)-1, 0, -1):
        for low in range(index):
            if l[low] > l[low+1]:
                tmp = l[low+1]
                l[low+1] = l[low]
                l[low] = tmp
    return l

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys


def resolve():
    readline = sys.stdin.readline

    N, K = map(int, readline().split())
    P = sorted([int(x) for x in readline().split()])

    print(sum(P[:K]))

resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def resolve():
    readline = sys.stdin.readline

    N, K = map(int, readline().split())
    P = [int(x) for x in readline().split()]

    P = sorted(P)

    print(sum(P[:K]))

resolve()

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 = [0 for _ in range(n)]
p = [int(s) for s in input().split()]
p.sort()

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

print(sm)

Submission status: Accepted

Solution code:
import sys
N,K = map(int,input().split())
array = [ I for I in map(int,input().split()) if (1 <= I <= 1000) ]

if not ( 1 <= K <= N and K <= N <= 1000 ): sys.exit()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():

    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)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
total,amount=[int(x) for x in input().split()]
array=sorted([int(x) for x in input().split()])
print(sum(array[0:amount]))

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 = int(input())
n, k = map(int, input().split())
l = list(map(int, input().split()))
#s = input()

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

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


def main():
    solve()


if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
_,K,*P=map(int,open(0).read().split())
print(sum(sorted(P)[:K]))

Submission status: Accepted

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

P.sort()

ans = sum(P[0:K])

print(ans)

Submission status: Accepted

Solution code:
import math
import sys
from collections import Counter
readline = sys.stdin.readline


def main():
    n, k = map(int, readline().rstrip().split())
    P = sorted(list(map(int, readline().rstrip().split())))
    print(sum(P[0: k]))


if __name__ == '__main__':
    main()

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:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import itertools
import math
import sys

INF = float('inf')


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


def main():

    sys.setrecursionlimit(10 ** 6)

    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]"
    print(solve(N, K, p))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(sum(nums[:k]))

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

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

P.sort()

# print(P)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
n=list(map(int,input().split()))[:a]
n.sort()
sum=0

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

print(sum)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

sorted_P = sorted(P)

print(sum(sorted_P[:K]))

Submission status: Accepted

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

sorted_lis = sorted(p_lis)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

n, k = inpl()
p = inpl()
p = sorted(p)
ans = 0
for i in range(n):
    ans += p[i]
    if i+1 == k:
        break
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()))
ans = 0

p.sort()
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()
total=0

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(total)