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

Submission status: Accepted

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

P.sort()

ans=sum(P[0:K])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n, k = M()
p = LI()
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())
List = list(map(int, input().split()))
List.sort()
num=0
for i in range(K):
    num+=List[i]
print(num)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ps = sorted(ps)

print(sum(ps[:k]))

Submission status: Accepted

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

p.sort()

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

p.sort()

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

print(total)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k = mi()
p = li()

p.sort()

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

Submission status: Accepted

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

result = 0

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

print(result)

Submission status: Accepted

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

n, k, *lst = map(int, read().split())
lst.sort()
print(sum(lst[:k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#                           जय श्री राम

import sys; import math; from collections import *
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().split())
def get_list(): return list(get_ints())
def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9+7); SEXYMOD = 998244353; MAXN = int(1e5)

#sys.stdin  = open("input.txt","r"); sys.stdout = open("output.txt","w")

# for _testcases_ in range(int(input())):
n, k = get_ints()
li = get_list()
print(sum(sorted(li)[:k]))


'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

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
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

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

    n,k=map(int, readline().rstrip().split())
    pp=list(map(int, readline().rstrip().split()))
    pp.sort()
    ans=0
    for i in range(k):
        ans+=pp[i]
    print(ans)
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Submission status: Accepted

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

resolve()

Submission status: Accepted

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

print(sum(li[: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())

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

list.sort()

ans = 0
for i in range(k):
    ans += list[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 = int(0)
for i in range(min(n,k)):
    ans += p[i]

print(ans)

Submission status: Accepted

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

print(sum(ans))

Submission status: Accepted

Solution code:
def main():
    N,K = map(int,input().split())
    p = list(map(int,input().split()))
    
    list.sort(p)
    ans = sum(p[0:K])
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
P = [int(x) for x in stdin.readline().rstrip().split()]
P.sort()
print(sum(P[:K]))

Submission status: Accepted

Solution code:
#B - Mix Juice
N,K= map(int,input().split())
p= list(map(int,input().split()))

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

plist.sort()

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

print(m)

Submission status: Accepted

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

pi.sort()

ans = 0

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

Submission status: Accepted

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res


N,K=LI()
PS=LI()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
#N = input()
N, K = map(int, input().split())
PList = list(map(int, input().split()))

PList.sort()
PList=PList[:K]
print(sum(PList))

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

p.sort()

sum = 0
for i in range(NK[1]):
    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:
n,k = map(int,input().split())
p_list = list(map(int,input().split()))

p_list_sorted = sorted(p_list)

print(sum(p_list_sorted[:k]))

Submission status: Accepted

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

n,k = imap()
p = sorted(iarr())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ya():
  print("Yes")
  return
def na():
  print("No")
  return


a,b=map(int,input().split())
lis=list(map(int,input().split()))
#n=int(input())
lis.sort()
ans=0
for i in lis[:b]:
  ans+=i
print(ans)

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

Submission status: Accepted

Solution code:
N, K = list(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, *p = map(int, open(0).read().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 = sorted(p)
    print(sum(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:
#!/usr/bin/env python3
n, k = map(int, input().split())
p = sorted(map(int, input().split()))
print(sum(p[:k]))

Submission status: Accepted

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

Submission status: Accepted

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

out = 0
for i in range(k):
    minp = min(ps)
    out += minp
    ps.remove(minp)
print(out)

Submission status: Accepted

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


price.sort()

ans=sum(price[i] for i in range(K))
print(ans)

Submission status: Accepted

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

sp = sorted(p)
ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

values = sorted(p)

print(sum(values[:K]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
arr = list(map(int, input().split()))
arr = sorted(arr)
print(sum(arr[: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:
## necessary imports
import sys
input = sys.stdin.readline
#from math import ceil, floor, factorial;

# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp

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

## nCr function efficient using Binomial Cofficient
def nCr(n, k): 
    if(k > n - k): 
        k = n - k 
    res = 1
    for i in range(k): 
        res = res * (n - i) 
        res = res / (i + 1) 
    return int(res) 

## upper bound function code -- such that e in a[:i] e < x;
def upper_bound(a, x, lo=0):
    hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x:
            lo = mid+1
        else:
            hi = mid
    return lo

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0 and n > 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0 and n > 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p): 
    res = 1
    x = x % p  
    if (x == 0) : 
        return 0
    while (y > 0) : 
        if ((y & 1) == 1) : 
            res = (res * x) % p 
        y = y >> 1      
        x = (x * x) % p 
    return res 

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b

# find function with path compression included (recursive)
# def find(x, link):
#     if link[x] == x:
#         return x
#     link[x] = find(link[x], link);
#     return link[x];

# find function with path compression (ITERATIVE)
def find(x, link):
    p = x;
    while( p != link[p]):
        p = link[p];
    
    while( x != p):
        nex = link[x];
        link[x] = p;
        x = nex;
    return p;


# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n): 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e6 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
# spf = [0 for i in range(MAXN)]
# spf_sieve() 
def factoriazation(x):
    ret = {};
    while x != 1:
        ret[spf[x]] = ret.get(spf[x], 0) + 1;
        x = x//spf[x]
    return ret
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()))
## taking string array input
def str_array():
    return input().strip().split();

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

n, k = int_array(); a = sorted(int_array());
print(sum(a[:k]));

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

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

Submission status: Accepted

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

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

Submission status: Accepted

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

p = sorted(p)

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

print(res)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

flist.sort()

print(sum(flist[: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:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np
import math
from collections import deque
from collections import defaultdict
from math import gcd




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

P.sort()
print(int(sum(P[:K])))

Submission status: Accepted

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

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:
def solve():
    print(sum(sorted(p)[: K]))

if __name__ == "__main__":
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def solve():
    ans = 0
    for i in range(k):
        ans += arr[i]
    return ans



if __name__ == '__main__':
    n, k = map(int, input().split())
    arr = sorted(list(map(int, input().split())))
    print(solve())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def minimize(k, ps):
    qs = sorted(ps)
    return sum(qs[:k])


def main():
    n, k = (int(z) for z in input().split())
    ps = [int(p) for p in input().split()]
    res = minimize(k, ps)
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


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


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


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


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N, K = MI()
    p = LI()
    p.sort()
    ans = 0
    for i in range(K):
        ans += p[i]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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:
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    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(sys.stdin.readline, print)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
n,k=map(int,input().split())
a=list(map(int,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 = sorted(map(int, input().split()))

print(sum(P[:K]))

Submission status: Accepted

Solution code:
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n,k = NextInts()
print(sum(sorted(NextIntList())[:k]))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
from math import *

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

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

print(ans)

Submission status: Accepted

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

slis = sorted(lis)

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(P[:K]))

Submission status: Accepted

Solution code:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N, K = next(it), next(it)
    P = list(it)
    P.sort()
    print(sum(P[:K]))

if __name__ == "__main__":
    resolve()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

print(np.sum(fruits[:K]))

Submission status: Accepted

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

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

Submission status: Accepted

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