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:
"""
    Satwik_Tiwari ;) .
    20 june , 2020  - Tuesday
"""

#===============================================================================================
#importing some useful libraries.
from __future__ import division, print_function

from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase


import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
#If the element is already present in the list,
# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect
#If the element is already present in the list,
# the right most position where element has to be inserted is returned

#==============================================================================================

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

# inp = lambda: sys.stdin.readline().rstrip("\r\n")

#===============================================================================================
#some shortcuts

mod = 1000000007
def inp(): return sys.stdin.readline().rstrip("\r\n") #for fast input
def out(var): sys.stdout.write(str(var))  #for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def graph(vertex): return [[] for i in range(0,vertex+1)]
def zerolist(n): return [0]*n
def nextline(): out("\n")  #as stdout.write always print sring.
def testcase(t):
    for p in range(t):
        solve()
def printlist(a) :
    for p in range(0,len(a)):
        out(str(a[p]) + ' ')
def lcm(a,b): return (a*b)//gcd(a,b)
def power(a,b):
    ans = 1
    while(b>0):
        if(b%2==1):
            ans*=a
        a*=a
        b//=2
    return ans
def ncr(n,r): return factorial(n)//(factorial(r)*factorial(max(n-r,1)))
def isPrime(n) : # Check Prime Number or not
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

#===============================================================================================
# code here ;))


def solve():
    n,k = sep()
    a = sorted(lis())
    print(sum(a[:k]))


testcase(1)
# testcase(int(inp()))

Submission status: Accepted

Solution code:
#B
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()

ans = []
for i in range(k):
    ans.append(p[i])
    
print(sum(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:
N,K=map(int,input().split())
P=list(map(int,input().split()))
P.sort()
print(sum(P[:K]))

Submission status: Accepted

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


if __name__ == '__main__':
    main()

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

    ans = 0
    for idx in range(k):
        ans += p[idx]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

import numpy as np

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

print(sum)

Submission status: Accepted

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n,k = readInt()
    p = readInt()
    p.sort()
    ans = 0
    for i in range(k):
        ans += p[i]
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

N,K=(int(x) for x in input().rstrip('\n').split())
As = sorted([int(x) for x in input().rstrip('\n').split()])
print(sum(As[: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:
def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]
    prices = [int(item) for item in input().split()]

    prices.sort()

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

    print(res)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

new = sorted(P)

ans = 0

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

p.sort()

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

print(total_min)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x,y = map(int,input().split())
n = sorted(list(map(int,input().split())))
print(sum(n[: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=ans+p[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

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:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, K = read_ints()
    p = read_ints()
    p.sort()
    return sum(p[:K])


if __name__ == '__main__':
    print(solve())

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

Submission status: Accepted

Solution code:
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:(input())
ips=lambda:input().split()

"""========main code==============="""
a,b=ml()
n=ll()
n.sort()
print(sum(n[:b]))

Submission status: Accepted

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

Submission status: Accepted

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

P.sort()
if k<n:
  print(sum(P[:k]))
else:
  print(sum(P))

Submission status: Accepted

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

Submission status: Accepted

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

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

a = p[0:K]

print(sum(a))

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    P = [int(p) for p in input().split()]
    P.sort()
    ans = sum(P[:K])
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

    p_sort = sorted(p)

    print(sum(p_sort[:K]))


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

Submission status: Accepted

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


a_list.sort()

sumn=sum(a_list[:K])


print(sumn)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#n=int(input())
#h=list(map(int,input().split()))
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:
def resolve():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))
    p.sort()
    print(sum(p[:k]))
resolve()

Submission status: Accepted

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

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

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

print(sum(p[:K]))

Submission status: Accepted

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


def solve(N: int, K: int, p: "List[int]"):
    p.sort()

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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import numpy as np
import functools
import operator
import collections
import itertools

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

Submission status: Accepted

Solution code:
import math
#map(int,input().split())
#int(x) for x in input().split()
#for _ in range(int(input())):
n,k=map(int,input().split())
l=[int(x) for x in input().split()]
l.sort()
print(sum(l[:k]))

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import *
from math import *

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

Submission status: Accepted

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

price = sorted(price)

print(sum(price[:num_buy]))

Submission status: Accepted

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

print(sum(nedan[:K]))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n, k, *ppp = map(int, sys.stdin.buffer.read().split())
ppp.sort()
print(sum(ppp[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
P=list(map(int,input().split()))
P1=sorted(P)
ans=0
for i in range(K):
    ans+=P1[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:
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:
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    N, K = map(int, input().split())
    p = list(map(int, input().split()))

    #output
    p = sorted(p)
    answer = sum(p[:K])
    print(answer)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

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

Submission status: Accepted

Solution code:
import sys
N, K = list(map(int, sys.stdin.readline().rstrip().split())) 
P = list(map(int, sys.stdin.readline().rstrip().split())) 

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

Submission status: Accepted

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

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

print(sum(P[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
a.sort()
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[0:K]))

Submission status: Accepted

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

    p.sort()

    print(sum(p[:K]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(a)

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

N, K = MAP()
A = LIST()

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

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]


N,K = map(int, input().split())
p = [int(i) for i in 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()

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

Submission status: Accepted

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

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

p.sort()

print(sum(p[:K]))

Submission status: Accepted

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,k = MI()
p = RI()

p.sort()

q = p[:k]

ans = sum(q)

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict, deque
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))
  
n,m=rm()
a=rl()
a.sort()
print(sum(a[:m]))

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
p = list(map(int, input().split()))
res = 0

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

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

Submission status: Accepted

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

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:
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    n,k = mi()
    p = li()
    p = list(sorted(p))
    ans = 0
    for i in range(k):
        ans+=p[i]
    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
# readline = sys.stdin.readline
read = sys.stdin.read
def main():
    n, k, *p = map(int, read().split())  # 1行目にnとk,2行目にh0,h1,,,hn
    p.sort()
    r = sum(p[:k])
    print(r)

if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
N_list = sorted(list(map(int, input().split())))
print(sum(N_list[: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:
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())
S=list(map(int,input().split()))

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

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()
minprice = sum(p[:k])

print(minprice)

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:

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

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()
    print(sum(p[:k]))

if __name__ == '__main__':
    main()

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

result = 0

P_soreted = sorted(P)
for i in range(K):
    result += P_soreted[i]
print(result)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

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