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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, k = mi()
    L = sorted(lmi())
    print(sum(L[:k]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

plist = list(map(int,input().split()))
plist.sort()
lists = plist[:int(k)]

print(sum(lists))

Submission status: Accepted

Solution code:
import sys


def main():
    input = sys.stdin.buffer.readline
    n, k = map(int, input().split())
    ps = sorted(map(int, input().split()))
    print(sum(ps[0:k]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

p.sort()

print(sum(p[:k]))

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    n, k = [int(x) for x in stdin.readline().rstrip().split()]
    p = [int(x) for x in stdin.readline().rstrip().split()]
    p.sort()
    fee = 0
    for i in range(k):
        fee += p[i]

    print(fee)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

P.sort()

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

print(tot)

Submission status: Accepted

Solution code:
m = list(map(int, input().strip().split(' ')))
n = list(map(int, input().strip().split(' ')))
n.sort()

res = 0
for i in range(m[1]):
	res+=n[i]
print(res)

Submission status: Accepted

Solution code:
N, K = 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] = list(map(int, input().split()))
pList = list(map(int, input().split()))
price = 0
for i in range(k):
    price += pList.pop(pList.index(min(pList)))
print(price)

Submission status: Accepted

Solution code:


def resolve():
    import sys
    input = sys.stdin.readline
    nk = input().rstrip().split(" ")
    pn = [int(p) for p in input().rstrip().split(" ")]
    pn.sort()
    print(sum(pn[:int(nk[1])]))




if __name__ == "__main__":
    resolve()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

p_new = sorted(p)

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


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


print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
n,k = map(int, sys.stdin.readline().rstrip("\n").split())
p = [int(s) for s in sys.stdin.readline().rstrip("\n").split()]
p.sort()
print(sum(p[:k]))

Submission status: Accepted

Solution code:
import sys

Line = [int(s) for s in input().split()]

N,K = Line[0],Line[1]

Line = [int(s) for s in input().split()]

Line.sort()

# print(Line)

ans = 0
count = 0

for i in Line:
    ans += i
    count +=1
    if count == K:
        print(ans)
        sys.exit()

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

A.sort()

print(sum(A[:k]))

Submission status: Accepted

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

p.sort()

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

print(ans)

Submission status: Accepted

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

def main():
    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)


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:
# Mix Juice
def fruits(arr, k):
    arr.sort()
    ans = 0
    while k:
        ans += arr.pop(0)
        k -= 1
    return ans



n, k = list(map(int, input().rstrip().split()))
ar = list(map(int, input().rstrip().split()))
print(fruits(ar, k))

Submission status: Accepted

Solution code:
# 2020/06/21
# AtCoder Beginner Contest 171 - B

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

# Calc
p.sort()

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

# Output
print(ans)

Submission status: Accepted

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

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

y.sort()

sum1 = 0
for i in range(b):
    sum1 += y[i]
print(sum1)

Submission status: Accepted

Solution code:
N,K = list(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 = 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()
sum = 0

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


def count_sort(array: List[int]) -> List[int]:
    max_num = max(array)
    min_num = min(array)

    count_element = [0] * (max_num - min_num + 1)
    for element in array:
        count_element[element - min_num] += 1

    result = []
    for index, cnt in enumerate(count_element, start=min_num):
        result.extend([index] * cnt)

    return result


def main() -> None:
    N, K = map(int, input().split(' '))
    array = [int(_) for _ in input().split(' ')]

    print(sum(count_sort(array)[:K]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from functools import reduce


def input():
    return sys.stdin.readline()[:-1]


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

print(sum(P[:K]))

Submission status: Accepted

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

p_list = sorted(p_list)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def S():
    return input().rstrip()


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


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


n, k = MI()
pl = list(MI())

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

num_list.sort()
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
arr = []
ans = 0

for i in range(N):
  arr.append(p[i])
arr= sorted(arr)

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

print(ans)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))
ZIP = lambda: zip(*(MAP() for _ in range(n)))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, K = MAP()
    P = LIST()

    P.sort()

    print(sum(P[:K]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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



if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

arr = [int(x) for x in input().split()]

arr.sort()
ans = 0
while k > 0:
    ans += arr[0]
    arr.pop(0)
    k -= 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(c)

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(p[:K]))

Submission status: Accepted

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

p.sort()

for 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 = sorted(L)
A = 0

for i in range(k):
    A += L[i]

print(A)

Submission status: Accepted

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

P.sort()

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

print(answer)

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

q = sorted(p)

print(sum(q[:k]))

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n,m = map(int, input().split())
    a_list = list(map(int, input().split()))
    a_list.sort()
    sum_num = 0
    for i in range(m):
        sum_num += a_list[i]
    print(sum_num)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,K=list(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
N,K=map(int, sys.stdin.readline().split())
P=map(int, sys.stdin.readline().split())
P.sort()
print sum(P[:K])

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

import sys

def main():
    fruit_list=[]
    n,m = map(int,input().split())
    fruit_list= [int(i) for i in input().split()]
    fruit_list=sorted(fruit_list)
    print(sum(fruit_list[:m]))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#s = input()
#n = int(input())
#s,t = input().split()
#n,m = map(int,input().split())
#a = list(map(int,input().split()))
#w = [int(input()) for _ in range(N)]


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

p_sort = sorted(p)

num = 0

for i in range(k):
    num += p_sort[i]
    
print(num)

Submission status: Accepted

Solution code:
from functools import reduce

N, K = [int(x) for x in input().split()]
P = sorted([int(x) for x in input().split()])
print(reduce(lambda x, y: x + y, P[0:K]))

Submission status: Accepted

Solution code:
def main():
    N,K = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]
    ans = 0
    for i,p in enumerate(sorted(P)):
        if i == K:
            break
        ans += p
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Ps.sort()

#print(Ps)
ans = 0
for P in Ps[:K]:
    ans += P

print(ans)

Submission status: Accepted

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

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


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:
# N, K = 5, 3
# ARR = [50, 100, 80, 120, 80]
#
#
# N,K = 1, 1
# ARR = [1000]

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


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

print(result)

Submission status: Accepted

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

ans = []
for k in range(K):
    ans.append(min(P))
    P.remove(min(P))

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

P.sort()
if k <= n:
    print(sum(P[:k]))
else:
    print(sum(P) + P[0]*(k-n))

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

Submission status: Accepted

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

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:
n,k = map(int ,raw_input().split(' '))
prices = map(int, raw_input().split(' '))
prices.sort()
print sum(prices[:k])

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

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

    print(t)


if __name__ == '__main__':
    t=1
    for _ in range(t):
        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:

import math

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#N = int(input())
#A = list(map(int, input().split()))
#a, b = map(int, input().split())
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())))

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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = list(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()))

p = sorted(p)

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n,k = [int(i) for i in input().split()]
num = [int(i) for i in input().split()]
num.sort()
cont=0
i=0
for i in num:
    if k<=0: break
    cont+=i
    k-=1
print(cont)

Submission status: Accepted

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

Submission status: Accepted

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

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

p.sort()

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

print(str(sum))

Submission status: Accepted

Solution code:
import sys
import numpy as np

# 実行環境(0:vscode, 1:atcoder)
MODE = 1

# 入力の次元
DIMENSION = 2

# int型に変換
INT_TYPE = 1

if not (MODE):
    with open("input.txt", "r") as f:
        s = f.read()
else:
    s = sys.stdin.read()

if DIMENSION == 0:
    if INT_TYPE == 1:
        s = int(s)
elif DIMENSION == 1:
    if INT_TYPE == 0:
        s = s.split()
    elif INT_TYPE == 1:
        s = [int(x) for x in s.split()]
elif DIMENSION == 2:
    if INT_TYPE == 0:
        s = [x.split() for x in s.splitlines()]
    elif INT_TYPE == 1:
        s = [[int(y) for y in x.split()] for x in s.splitlines()]

N, K = s[0]
p = s[1]
p.sort()
print(sum(p[:K]))

Submission status: Accepted

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

PS = sorted(PS, reverse=False)

#print(PS)
#print(PS[:K])
print(sum(PS[:K]))

Submission status: Accepted

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


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n, k = input_to_int_map()
    p = input_to_int_tuple()

    p_sorted = sorted(p)

    return sum(p_sorted[:k])

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

Submission status: Accepted

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

    return

resolve()

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

Submission status: Accepted

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

a.sort()

v = 0;
for i in range(k):
    v = v + a[i];
    
print(v)

Submission status: Accepted

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

p.sort()
c = 0

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

print(c)

Submission status: Accepted

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

p.sort()

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

print(r)

Submission status: Accepted

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

n, k = map(int, input().split())
p = list(map(int, input().split()))
enum = list(enumerate(p))
enum.sort(key=lambda x: x[1])
res = 0

for i in range(k):
    res += enum[i][1]

print(res)

Submission status: Accepted

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

sum = 0

a_sorted = sorted(a)

for cnt in range(k):
    sum += a_sorted[cnt]

print(sum)

Submission status: Accepted

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

sum_ = 0
for i in range(K):
  min_ = min(p)
  argmin = p.index(min_)
  del p[argmin]
  sum_ += min_

print(sum_)

Submission status: Accepted

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

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