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:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, k = tin()
	#s = input()
	al = lin()
	al.sort()
	ret = sum(al[:k])
	print(ret)
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# n=int(input())
# arr=list(map(int,input().split(" ")))
inp=input().split()
a,b=int(inp[0]),int(inp[1])
arr=list(map(int,input().split(" ")))
arr.sort()
print( sum(arr[:int(b)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = list(map(int,input().split()))
N = i[0] # 販売されている種類
K = i[1] # 買う種類数

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

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

Submission status: Accepted

Solution code:
syu,ko = map(int,input().split())

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

jyu_list.sort()

goukei = 0

for i in range(ko):
    goukei = goukei+jyu_list[i]

print(goukei)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

P.sort()

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
fruits = input().split()
fruits = [int(s) for s in fruits]
fruits.sort()
sum = 0
for i in range(K):
    sum = sum + fruits[i]
    i +=1
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()

print(sum(p[:k]))

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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


from collections import deque  #listよりdequeの方が両端へのアクセスは計算量が少ない
def main():
    n, k =map(int,input().split())
    p = list(map(int,input().split()))
    p.sort()
    s = sum(p[:k])
    print(s)	


if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
if __name__ == '__main__':

    N, K = [int(x) for x in input().split(' ')]
    L2 = sorted([int(x) for x in input().split(' ')])

    pick_sum = 0
    for i in range(K):
        pick_sum = pick_sum + L2[i]

    print(pick_sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(sorted(prices)[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 全何種類で何種類買うか取得
n,k = map(int, input().split())
# 値段を格納
prices = [int(p) for p in input().split()]
# ソート
prices.sort()
#最安値を出力
print("%d" % sum(prices[:k]))

Submission status: Accepted

Solution code:
import sys



def solve(n):
    #print(n)
    NCHARS = int(26)
    MAXVAL = NCHARS
    ndigs = 1
    while n > MAXVAL:
        ndigs += 1
        n -= MAXVAL
        MAXVAL *=  NCHARS
    # now have # digs
    #print(n,ndigs,MAXVAL)
    n -= 1
    result = ''
    while n > 0:
        #print(n,MAXVAL,NCHARS)
        #MAXVAL //= NCHARS
        result += chr(n%NCHARS + ord('a'))
        n //= NCHARS
        #d = n // MAXVAL
        #d = n // MAXVAL
        #print(n,MAXVAL,result)
    if len(result) < ndigs:
        result += ''.join(['a' for i in range(ndigs-len(result))])
    print(''.join([c for c in result][::-1]))
        

        


if __name__ == '__main__':
    IN = [x.strip() for x in sys.stdin.readlines()]

    n,k = [int(x) for x in IN[0].split(' ')]
    vals = [int(x) for x in IN[1].split(' ')]
    print(sum(sorted(vals)[:k]))

Submission status: Accepted

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

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

price.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

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 = list(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())
x = list(map(int,input().split()))
x.sort()
print(sum(x[: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:
if __name__ == "__main__":
    N,k = [int(item) for item in input().split()]
    price_arr = [int(p) for p in input().split()]
    print(sum(sorted(price_arr)[: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:
import sys
import math
#import random
#sys.setrecursionlimit(1000000)
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

n,k=invr()
ara=inara()

ara.sort()

ans=0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x = input()
y = input()

a = list(map(int, x.split()))
b = list(map(int, y.split()))

K = a[1]
b = sorted(b)

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

Submission status: Accepted

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

jpy = 0

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

print(jpy)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[int(x) for x in 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(' ')))
ordered = sorted(p)
print(sum(ordered[:k]))

Submission status: Accepted

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

array = list(map(int, input().split()))
array.sort()
total = 0

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

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:
N, K = map(int,input().split())
L = list(map(int,input().split()))
L.sort()
total = 0
for i in range(K):
    total += L[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:
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:
#関数リスト
import sys
input = sys.stdin.readline

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n, k = MI()
mylist = LI()
mylist.sort()
print(sum(mylist[0:k]))

Submission status: Accepted

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


def main():
    import sys
    input = sys.stdin.readline

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

    print(sum(p[:k]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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:
# coding: utf-8
# Your code here!

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

print(sum(p[:K]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split(' '))
s = list(map(int, input().split(' ')))
ans = 0
s.sort()

for i in range(k):
    ans = ans + s[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[:k]))

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
c=[]
c=map(int,input().split())
d=list(c)
d2=sorted(d)
ans=0
for i in range(b):
  ans+=d2[i]
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

new_list = sorted(list)
pay = 0

for i in range(K):
    pay = pay + new_list[i]
print(pay)

Submission status: Accepted

Solution code:
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    print sum(p[:k])
    return




n, k = RA()
p = sorted(RA())
solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc171/tasks/abc171_b
[n, k]=[int(i) for i in input().split()]
p=[int(i) for i in input().split()]

p.sort()


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

print(sum)

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
s = list(map(int,input().split()))
s.sort()
ss = s[:b]
print(sum(ss))

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

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

Submission status: Accepted

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

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

  price.sort()

  part = price[0:K]

  print(sum(part))

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:
#!/usr/bin/env python3
import sys
import numpy as np
input = sys.stdin.readline
x,y = map(int,input().split()) 
A= list(map(int,input().split()))
A.sort()
print(sum(A[:y:]))

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

Submission status: Accepted

Solution code:
num, buy = [int(x) for x in input().split(' ')]

p_arr = map(int, input().split(' '))

sp = sorted(list(p_arr))

print(sum(sp[:buy]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(sorted(price_list)[0:k]))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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:
a,n=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
summ=0
for i in range(n):
    summ+=l[i]
print(summ)

Submission status: Accepted

Solution code:
info = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]

q.sort()

ans = 0;
for i in range(info[1]):
  ans += q[i]

print(ans)

Submission status: Accepted

Solution code:
N, K = (int(x) for x in input().split())
p = list(int(x) for x in input().split())

sorted_new = sorted(p)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = [int(w) for w in input().split()]
p_li = [int(w) for w in input().split()]

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

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
ans = 0
for i,v in enumerate(p):
    ans += v
    if i == K - 1:
        print(ans)
        exit()
print(ans)

Submission status: Accepted

Solution code:
N,K,*p = map(int,open(0).read().split())
p.sort()
print(sum(p[:K]))

Submission status: Accepted

Solution code:
read = lambda : list(map(int, input().split()))
n, k = read()
p = read()
p.sort()
ans = sum(p[:k])
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(" "))
price=list(map(int,input().split(" ")))
price.sort()
#print(price)
price=price[:k]
print(sum(price))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

for i in range(0,s[1]):
	a.append(p[i])
print(sum(a))

Submission status: Accepted

Solution code:
import heapq
n, k = map(int, input().split())
fruits = list(map(int, input().split()))
heapq.heapify(fruits)
print(sum(heapq.nsmallest(k, fruits)))

Submission status: Accepted

Solution code:
#-- coding: utf-8 --
#スペース区切りの整数の入力
a, b = map(int, input().split())
#配列の入力
array = list(map(int, input().split()))
#配列を降順に並び替え
array.sort()
#配列をbでスライス
del array[b:]
#配列を足して出力
print(sum(array))

Submission status: Accepted

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

Submission status: Accepted

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


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    # 標準入力の取得
    N, K = list(map(int, input().split()))
    p = list(map(int, input().split()))

    return N, K, p


def main(K: int, p: list) -> None:
    """
    求解処理.

    Args:
        K (int): 購入する果物の種類
        p (list): 各果物の価格
    """
    # 求解処理
    sorted_p = sorted(p)
    ans = sum(sorted_p[:K])

    # 結果出力
    print(ans)


if __name__ == "__main__":
    N, K, p = get_input()
    main(K, p)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=[]
l=list(map(int,input().split()))
l.sort()
print(sum(l[0: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 = [int(x) for x in input().split()]

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(sum)

Submission status: Accepted

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

print(sum(sorted(li_p)[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

p_list.sort()

num = 0

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

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

B.sort()

print(sum(B[:A[1]]))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(arr[:k]))

Submission status: Accepted

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

prices.sort()

sum = 0
for i in range(K_ko):
    sum += prices[i]
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(l[:b]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def quick_sort(plices):
    if len(plices) == 1:
        return plices


    cri = plices[0]
    left = []
    right = []

    for i in range(1, len(plices)):
        if plices[i] < cri:
            left.append(plices[i])

        else:
            right.append(plices[i])

    left.append(cri)

    return quick_sort(left) + quick_sort(right)

def cal_sum(sorted_plices, K):
    min_sum = 0
    for i in range(K):
        min_sum += sorted_plices[i]

    return min_sum


if __name__ == "__main__":

    N, K = map(lambda x:int(x), input().split())
    plices = [int(i) for i in input().split()]

    # sorted_plices = quick_sort(plices)
    sorted_plices = sorted(plices)
    # print(sorted_plices)
    min_sum = cal_sum(sorted_plices, K)

    print(min_sum)

Submission status: Accepted

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


def solve(N: int, K: int, p: "List[int]"):
    print(sum(sorted(p)[:K]))
    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:
from sys import stdin
data = stdin.readlines()

n = list(data[0].split())[0]
k = int(list(data[0].split())[1])

l = [int(s) for s in data[1].split()]
l_sorted = sorted(l)

i = 1
price = 0
while i <= k:
    price += l_sorted[i-1]
    i += 1

print(price)

Submission status: Accepted

Solution code:
import sys
# from math import sqrt, gcd, ceil, log
# from bisect import bisect
# from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n, k = read(); arr = sorted(read())
	print(sum(arr[:k]))



if __name__ == "__main__":
	solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

a.sort()

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

Submission status: Accepted

Solution code:
N,K = (int(x) for x in input().split())
list = []
list = (int(x) for x in input().split())
new_list = sorted(list)
del new_list[K:]
print(sum(new_list))

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

q=sorted(p)

print(sum(q[:K]))

Submission status: Accepted

Solution code:
from collections import defaultdict
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')


if __name__ == '__main__':
    _, K = it()
    F = it()
    F.sort()
    print(sum(F[:K]))

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N = a[0]
K = a[1]

p.sort()

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case #{}: {}".format(i, o))


def solve(n, k, p):
    return sum(sorted(p)[:k])


if __name__ == "__main__":
    n, k = arr_in()
    p = arr_in()
    out(solve(n, k, p))

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    p=list(map(int,readline().split()))

    print(sum(sorted(p)[:k]))
    
if __name__=="__main__":
    main()

Submission status: Accepted

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

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:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
p = LI()

p.sort()

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

Submission status: Accepted

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

p.sort()
print(sum(p[: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, *P = map(int, open(0).read().split())
print(sum(sorted(P)[:K]))

Submission status: Accepted

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

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

print(ans)