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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# itne me hi thakk gaye?
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
s = 0
for i in range(m):
    s += a[i]
print(s)

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n, k = MII()
    pp = MII()
    pp.sort()
    print(sum(pp[:k]))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 21 21:01:51 2020

@author: NEC-PCuser
"""

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

p = p[:k]

print(sum(p))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


print(sum(L[:K]))

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    n,k = na()
    ps = na()
    ps.sort()
    print(sum(ps[:k]))
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int, input().split(' '))
l=list(map(int, input().split(' ')))
s=0
for i in range(k):
    m=min(l)
    s+=m
    l.pop(l.index(m))
print(s)

Submission status: Accepted

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

print(sum(P[:K]))

Submission status: Accepted

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


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

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
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]"
    print(solve(N, K, p))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

Solution code:
#coding: utf-8
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:
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n,k=rl()
p=rl()
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())

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

l.sort()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ps.sort()

ms = sum(ps[:k])
print(ms)

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

Submission status: Accepted

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

print(sum(p[:K]))

Submission status: Accepted

Solution code:
# Contest No.: ABC171
# Problem No.: B
# Solver:      JEMINI
# Date:        20200621

import sys
import heapq

def main():
    n, k = map(int, input().split())
    nums = list(map(int, sys.stdin.readline().split()))
    nums.sort()
    print(sum(nums[:k]))
    return

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:
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
#n = int(input())
n, k = map(int, sys.stdin.readline().split())
#s = input()
p = list(map(int, sys.stdin.readline().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()]
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())

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

print(sum(A[:K]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:


import sys
import math
import itertools
import collections

def solve(N,K,P):
    P.sort()
    ans = 0
    for i in range(K):
        ans += P.pop(0)
    return ans
def main():
    N,K = map(int,input().split())
    P = list(map(int,input().split()))
    # solve()
    print(solve(N,K,P))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod=1000000007
#mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')




# for _ in range(ii()):
    





n,k=mi()
a=li()
a.sort()
print(sum(a[:k]))

Submission status: Accepted

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

p = sorted(p)

print(sum(p[: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, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n, k = i_map()
    num_list = i_list()

    num_list.sort()

    count = 0

    for i in range(k):
        count += num_list[i]

    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import io,sys
sys.setrecursionlimit(10**6)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(sum(price[:K]))

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:
import sys
input = sys.stdin.readline

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

p.sort()

print(sum(p[:k]))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
INF = float('inf')


def main():
   N, K = map(int, readline().split())
   P = list(map(int, readline().split()))
   P.sort()
   ans = 0
   for i in range(K):
       ans += P[i]
   print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################


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

Submission status: Accepted

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

p.sort()

ans = 0

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

print(ans)

Submission status: Accepted

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

li.sort()

ans = 0

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

Submission status: Accepted

Solution code:
n, k, *P = map(int, open(0).read().split())
P.sort()
print(sum(P[:k]))

Submission status: Accepted

Solution code:
n_fruit, n_mustbuy = map(int,input().split())
price_ls = list(map(int, input().split()))
price_ls.sort()

print(sum(price_ls[:n_mustbuy]))

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]

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

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,k=n1()
P=n1()
P.sort()
print(sum(P[:k]))

Submission status: Accepted

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

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

l.sort()

print(sum(l[:k]))

Submission status: Accepted

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

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K, *P = map(int, read().split())

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

Submission status: Accepted

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
P=sorted([int(i) for i in input().split()])
print(sum(P[:k]))

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, k = geta(int)
    p = list(geta(int))

    p.sort()

    print(sum(p[:k]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

#print(A)

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())
print(sum(sorted(int(i) for i in input().split())[:k]))

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[: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:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



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

main()

Submission status: Accepted

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

print(sum(array[: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:
x,y = map(int,input().split())

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

t.sort()

print(sum(t[:y]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

p.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

p.sort()

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

'''

'''

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

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


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


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

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

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

print(sum(A[:K]))

Submission status: Accepted

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

print(sum(p_int_list_sorted[:K]))

Submission status: Accepted

Solution code:

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

print(sum(P[:K]))

Submission status: Accepted

Solution code:
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n, k = _ia()
    p = sorted(_ia())
    return sum(p[:k])


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,K = inputMap()
	p = inputList()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, k  = map(int, input().split())
l  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

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

Submission status: Accepted

Solution code:
import sys, collections, bisect, itertools, heapq, math, copy
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    p = LI()

    p.sort()

    print(sum(p[:K]))

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#float型を許すな
#numpyはpythonで
#dp
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


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


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


def get_ashi(x, y):
    return 2*x + 4*y


N, K = zz()
p = zz()
p = sorted(p)
print(sum(p[:K]))

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

Submission status: Accepted

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

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())
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:
import sys
def input(): return sys.stdin.readline().strip()


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
p_list = [int(e) for e in input().split()]

p_list.sort(reverse=False)

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

Submission status: Accepted

Solution code:
# ABC171 B 

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

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

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

PList.sort()
result = 0

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

print(result)

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

Submission status: Accepted

Solution code:
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    n, k = mput()
    p = lput()
    p.sort()
    ans = sum(p[:k])
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

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

    p.sort()
    print(sum(p[:K]))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

p.sort()

print(sum(p[:k]))

Submission status: Accepted

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

A.sort()

print(sum(A[:K]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#

import sys
input=sys.stdin.readline

def main():
    N,K=map(int,input().split())
    ps=list(map(int,input().split()))
    ps.sort()
    print(sum(ps[:K]))
    
    
    
if __name__=="__main__":
    main()

Submission status: Accepted

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

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