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

Submission status: Accepted

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

p = sorted(p)

SUM = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
fruits = [int(i) for i in input().split()]
prices = sorted([int(i) for i in input().split()])
value = 0
for i in range(0, fruits[1]):
    value += prices[i]
print(value)

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


def main(K, M):
    ans = 0
    p.sort()
    for i in range(K):
        ans += p[i]
    return ans


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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    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 = map(int, input().split())
pList = list(map(int, input().split()))

sortList = sorted(pList)
ans = 0
for i in range(K):
  ans += sortList[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[0:k]))

Submission status: Accepted

Solution code:
def sums(l):
	s = 0
	for v in l:
		s += v
	return s

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

print(sums(a[: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()

sum=0

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

print(sum)

Submission status: Accepted

Solution code:
[N,K] = [int(i) for i in input().split()]
P = sorted([int(i) for i in input().split()])
c = 0

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

print(c)

Submission status: Accepted

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

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

print(sum_)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(0, K): #range関数は、リストPの0~(K-1)までをforループで回す
    ans += P[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nums = [int(e) for e in input().split()]
p = [int(e) for e in input().split()]
p.sort()
print(sum(p[0:nums[1]]))

Submission status: Accepted

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

p_list.sort()
Ans=0

for i in range(0,K):
    Ans+=p_list[int(i)]

print(Ans)

Submission status: Accepted

Solution code:
l= input().split()
n= l[0]
k=int(l[1])

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

tot=0
for _ in range(k):
	tot+= p_s.pop(0)

print(tot)

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest


def resolve():
    # s = input()
    # n = int(input())
    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    p.sort()

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


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5 3
50 100 80 120 80"""
        output = """210"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 1
1000"""
        output = """1000"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

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 = []
for p in map(int,input().split()):
  P.append(p)
list.sort(P, reverse=True)
s = 0
for k in range(K):
  s += P.pop()
print(s)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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()))

m = sorted(p)

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

p.sort()

summ=0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

p.sort()

i=0
price=0
while i<k:
    price+=p[i]

    i+=1
    
print(price)

Submission status: Accepted

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

Submission status: Accepted

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

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

buy = sorted(p)
price = sum(buy[:K])
print(price)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__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)

Submission status: Accepted

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

Submission status: Accepted

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

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

sortp = sorted(p)
sum=0
for k in range(K):
    sum=sum+sortp[k]

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

print(sum)

Submission status: Accepted

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

p.sort()
ans = 0
cnt = 0
for i, value in enumerate(p):
    if i < k:
        ans += value
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

a = sorted(li)
print(sum(a[:K]))

Submission status: Accepted

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

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

Submission status: Accepted

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

p_list = sorted(p_list)
print(sum(p_list[:K]))

Submission status: Accepted

Solution code:
from itertools import combinations

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

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

A.sort()

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

print(ans)

Submission status: Accepted

Solution code:

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

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

p_list.sort()

sum_ = 0

for i in range(k):
    sum_ = sum_ + int(p_list[i])

print(sum_)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

l.sort()

sum=0

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

print(sum)

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

price = sorted(price)

print(sum(price[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

f_p.sort()
b_p = f_p[:K]

ans = sum(b_p)
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:
x,y = map(int, input().split())
p = input().split()
p1 = list(map(int, p))
p1.sort()
a = 0
for i in range(y):
    a = a + p1[i]
print(a)

Submission status: Accepted

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

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

Submission status: Accepted

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

res = 0

for k in range(K):
    t = p[0]
    c = 0
    for i in range(len(p)):
        if t > p[i]:
            t = p[i]
            c = i

    res += p.pop(c)

print(res)

Submission status: Accepted

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

p.sort()
t=0
for q in p[0:k]:
    t+=q
print(t)

Submission status: Accepted

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

N = i[0]
K = i[1]

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

p.sort()
sum = 0
for iter in range(K):
    sum += p[iter]

print(sum)

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

p.sort()

print(sum(p[:n]))

Submission status: Accepted

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

pd = sum(p[0:K])

print(pd)

Submission status: Accepted

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

ret=0
for i in range(K):
    ret+=list[i]
print(ret)

Submission status: Accepted

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

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

Submission status: Accepted

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

p = [int(n) for n in p]

p.sort()

res = 0

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

print(res)

Submission status: Accepted

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

newp0 = sorted(p)
newp1 = newp0[0:K]

print(sum(newp1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
"""AtCoder Beginner Contest 171: B - Mix Juice
https://atcoder.jp/contests/abc17/tasks/abc171_b
"""


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    total1 = list(map(int, input().split()))
    total = list(map(int, input().split()))

    num = total1[1]

    s_total = sorted(total)

    money = 0
    for i in range(num):
        money += s_total[i]

    print(money)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

#sortしてKの合計
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()))

ans = 0
for i in range(K):
    ans += min(p)
    p.remove(min(p))
print(ans)

Submission status: Accepted

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

print(sum(L[:k]))

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:
NK = input().split()
N = int(NK[0])
K = int(NK[1])

ps = input().split()

p = []

for i in range(N):
    p.append(int(ps[i]))

ans = 0


rp = sorted(p)

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
result = 0
for i in range(K):
  result += p[i]
print(result)

Submission status: Accepted

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

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

        return ans

if __name__=="__main__":
        ans = main()
        print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)

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

l.sort()

print(sum(l[:k]))

Submission status: Accepted

Solution code:
x,y = map(int,input().split())
li = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
P=sorted(p)
l=[]
cnt=0
for i in P:
  cnt+=1
  l.append(i)
  if cnt==k:
    break
print(sum(l))

Submission status: Accepted

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

list.sort()

print(sum(list[:k]))

Submission status: Accepted

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


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

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

Submission status: Accepted

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

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

l = sys.stdin.readline().rstrip('\n').split(' ')
N = int(l[0])
K = int(l[1])

l = sys.stdin.readline().rstrip('\n').split(' ')
prices = [int(i) for i in l]
prices.sort()

print(sum(prices[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import math
# from collections import Counter

# N = int(input()) # 1行, 単数
# arg = list(map(int, input().split())) # 1行, 配列
# D = Counter(arg) # 出現数カウント

# print('Yes')
# print('No')
# print()
N,K = list(map(int, input().split())) # 1行, 配列
p = list(map(int, input().split())) # 1行, 配列

p.sort()
cnt =0

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

print(cnt)

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()))
ans = 0

p.sort()

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

print(ans)

Submission status: Accepted

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

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

    return money

print(main())

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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_order = sorted(p)
ans = 0

p_ans = p_order[:k]
ans = sum(p_ans)
print(ans)

Submission status: Accepted

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

p.sort()
# print(p)

sum =0

for i, item in enumerate(p):
    if i== k:
        break
    sum += item

print(sum)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

cheaper_items = sorted(P)
print(sum(cheaper_items[:K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p2 = sorted(p)
ans = 0

for i in range(len(p2)):
    ans += p2[i]
    if i == k-1:
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,K = map(int,S().split())
p = LI()
p = sorted(p)

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007
INF = float('inf')

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x
    
def main():
    n, k = [int(x) for x in stdin.readline().rstrip().split()]
    p = list(map(int,[int(x) for x in stdin.readline().rstrip().split()]))
    sort_p = sorted(p)
    print(sum(sort_p[0:k]))
main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
line = input()
p_list = line.split(" ")
p_list = [int(p) for p in p_list]
p_list = sorted(p_list)
ans = 0

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

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

out=0
s = sorted(s)
for i in range(i[1]):
  out+=s[i]
print(out)

Submission status: Accepted

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

m.sort()

print(sum(m[:k]))

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:
def linked_merge_sort(l): #マージソート
    if len(l) == 1:
        return
    q, r = divmod(len(l), 2)
    left = [l.pop() for _ in range(q)]
    right = [l.pop() for _ in range(q + r)]
    
    linked_merge_sort(left)
    linked_merge_sort(right)
    
    left.reverse()
    right.reverse()
    while left and right:
        if left[-1] <= right[-1]:
            l.append(left.pop())
        else:
            l.append(right.pop())
    while left:
        l.append(left.pop())
    while right:
        l.append(right.pop())
    return

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

Submission status: Accepted

Solution code:
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=sorted(p)
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()))

sort = sorted(p)
s = 0

for i in range(k):
    s += sort[i]

print(s)

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

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

p.sort()
cost = 0

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

print(cost)

Submission status: Accepted

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, k) = [int(e) for e in lines[0].split(' ')]
    p = [int(e) for e in lines[1].split(' ')]

    return (n, k, p)


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


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

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

P = sorted(P)


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=list(map(int,input().split(" "))) # N,K
P=list(map(int,input().split(" "))) # 果物のリスト

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

Submission status: Accepted

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

print(sum(p[:K]))

Submission status: Accepted

Solution code:
N, k = 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]))