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: Wrong Answer

Solution code:
A=list(input().split(" "))
B=list(input().split(" "))
C=sorted(B)
D=[]
M=0
for i in range(int(A[1])):
    D.append(int(C[i]))
for j in range(len(D)):
    M=D[j]+M
print(M)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = [int(m) for m in input().split()]
p.sort()
ans = 0

if K == 1:
    print(*p)
elif K == 2:
    print(p[0]+p[1])
else:
    for i in range(K):
        ans += p[i]
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(sum(sorted(pi)[:N]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
N,K = map(int,input().split())
p = [int(m) for m in input().split()]
p.sort()

if K == 1:
    print(*p)
elif K == 2:
    print(p[0]+p[1])
else:
    p3list = list(itertools.combinations(p, 3))
    print(sum(min(p3list)))

Submission status: Wrong Answer

Solution code:
n = input()
m = n.split()
print(m)
a = [input() for l in range(0,1)]
b = a[0].split()
print(b)

for i in range(0, len(b)):
    b[i] = int(b[i])

c = sorted(b, reverse=True)
print(c)
p = 0
for i in range(int(m[0]) - int(m[1]),int(m[0])):
    p = p + int(c[i])
print(p)

Submission status: Wrong Answer

Solution code:
n = input()
m = n.split()
print(m)
a = [input() for l in range(0,1)]
b = a[0].split()
print(b)

for i in range(0, len(b)):
    b[i] = int(b[i])

c = sorted(b, reverse=True)
print(c)
p = 0
for i in range(int(m[0]) - int(m[1]),int(m[0])):
    p = p + int(c[i])
print(int(p))

Submission status: Wrong Answer

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

print(sum(l[:3]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K= map(int,input().split())
 
A = list(map(int,input().split()))
 
B = [1001 for i in range(K)]
 
for x in A:
    
  for i in range(K):
    if x < B[i]:
      B[i] = x
      break
 
S = 0
for y in B:
  S += y
print(S)

Submission status: Wrong Answer

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

print(sum(sorted(p_list)[:N]))

Submission status: Wrong Answer

Solution code:
A1, A2 = map(int, input().split())
B = list(map(int,input().split()))	

B.sort()
num = 0

for i in range(A2):
  num = B[i]

print(num)

Submission status: Wrong Answer

Solution code:
import itertools
N,K = map(int,input().split())
p = [int(m) for m in input().split()]

if K == 1:
    print(*p)

if K == 2:
    p2list = list(itertools.combinations(p, 2))
    print(sum(min(p2list)))
    
if K >= 3:
    p3list = list(itertools.combinations(p, 3))
    print(sum(min(p3list)))

Submission status: Wrong Answer

Solution code:
import itertools
N,K = map(int,input().split())
p = [int(m) for m in input().split()]

if K == 1:
    print(*p)
elif K == 2:
    p2list = list(itertools.combinations(p, 2))
    print(sum(min(p2list)))
else:
    p3list = list(itertools.combinations(p, 3))
    print(sum(min(p3list)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def order (p):
    return (sorted(p))         
def Mix_Juice (p, K):
    N = len (p)
    a = order (p)
    b = 0
    for i in range (0, K):
        b = b + a[i]
    return b
N,K = map(int, input().split())
p = list(map(int, input().split()))
Mix_Juice (p,K)

Submission status: Wrong Answer

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

P.sort()

print(sum(P[:3]))

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
if len(p) >= 3 :
    print(str(p[0] + p[1] + p[2]))
elif len(p) == 2 :
    print(str(p[0]+p[1]))
elif len(p) == 1 :
    print(str(p[0]))

Submission status: Wrong Answer

Solution code:
import sys

input_list = sys.stdin.readlines()

count = 1
get_count = 0
get_value_count = 0
output = 0
for i in input_list:
  get_values = i.split()
  if count == 1:
    get_value_count = int(get_values[0])
    get_count = int(get_values[1])
  else:
    if get_value_count == 1:
      print(get_values[0])
    else:
      new_list = sorted(get_values, key=int)
      count_value = 1
      for c in new_list:
        if count_value > get_count:
          break
        else:
          output = output + int(c)
        count_value = count_value + 1
  count = count + 1
print(str(output))

Submission status: Wrong Answer

Solution code:
N,K= map(int,input().split())
 
A = list(map(int,input().split()))
 
B = [1001 for i in range(K)]
 
for x in A:
  for i in range(K):
    if x < B[i]:
      B[i] = x
      break
 
S = 0
for y in B:
  S += y
print(S)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=map(int,input().split())
ans = sorted(a)
answer = ans[:3]
aaa = sum(answer)
print(aaa)

Submission status: Wrong Answer

Solution code:
n, k = input().split()
lists = list(input().split())
lists.sort()
sum_fruit = 0
for i in range(int(k)):
  sum_fruit = sum_fruit + int(lists.pop(-1))
print(str(sum_fruit))

Submission status: Wrong Answer

Solution code:
n, k = input().split()
lists = list(input().split())
lists.sort()
sum_fruit = 0
for i in range(int(k)):
  sum_fruit = sum_fruit + int(lists[-1 * (i+1)])
print(str(sum_fruit))

Submission status: Wrong Answer

Solution code:
a=input()
b=a.split()
c=input()
d=c.split()
N=int(b[0])
K=int(b[1])
p=[]
for i in range(N):
    p.append(int(d[i]))
p.sort()
print(p)
ans=0
for i in range(K):
    ans=ans+p[i]
print(ans)

Submission status: Wrong Answer

Solution code:
fluit_num,fluit_buy=input().split()
print(fluit_num,fluit_buy)
p = input().split()
print(p[:4])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

input_list = sys.stdin.readlines()

count = 1
get_count = 0
get_value_count = 0
for i in input_list:
  get_values = i.split()
  if count == 1:
    get_value_count = int(get_values[0])
    get_count = int(get_values[1])
  else:
    if get_value_count == 1:
      print(get_values[0])
    else:
      new_list = sorted(get_values, key=int)
      count_value = 1
      p = 0
      for c in new_list:
        if count_value > get_count:
          print(str(p))
          break
        else:
          p = p + int(c)
        count_value = count_value + 1
  count = count + 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
numberoffruitspicked = 1 
costoffruitone = 1000

minumcostofonefruit = costoffruitone 
print(minumcostofonefruit)

Submission status: Wrong Answer

Solution code:
k_n = list(map(int, input().split()))
p = list(map(int, input().split()))
p = sorted(p, reverse=False)
sum = 0
for i in range(k_n[0]):
    sum += p[i]
print(sum)

Submission status: Wrong Answer

Solution code:
import sys

input_list = sys.stdin.readlines()

count = 1
get_count = 0
get_value_count = 0
for i in input_list:
  get_values = i.split()
  if count == 1:
    get_value_count = int(get_values[0])
    get_count = int(get_values[1])
  else:
    if get_value_count == 1:
      print(get_values[0])
    else:
      get_values.sort()
      count_value = 1
      p = 0
      for c in get_values:
        if count_value > get_count:
          print(str(p))
        else:
          p = p + int(c)
        count_value = count_value + 1
  count = count + 1

Submission status: Wrong Answer

Solution code:
import sys
#果物の種類Nと，購入数K
N, K = map(int, input().split())

#果物値段A
A = list(map(int, input().split()))
A = sorted(A, reverse = False)
#print(N, K)
#print(A)
ans=0
#C = 0

for i in A:
    ans += A.pop(0)
    #print(ans)
    #print(ans)
    """
    if C == K-1:
        print(ans)
        sys.exit()
"""
print(ans)

Submission status: Wrong Answer

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

print(sum)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
mylist = input().split()
mylist.sort()
c = 0
print(mylist)
for i in range(b-1):
    c = c + int(mylist[i-1])
print(c)

Submission status: Wrong Answer

Solution code:
n = input()
m = n.split()
a = [input() for l in range(0,1)]
b = a[0].split()
c = sorted(b, reverse=True)
p = 0
for i in range(0,int(m[1])):
    p = p + int(c[i])
print(int(p))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
m = n.split()
a = [input() for l in range(0,1)]
b = a[0].split()
c = sorted(b, reverse=True)
p = 0
for i in range(0,int(m[1])):
    p = p + int(c[i])
print(p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

B=sorted(A)

for a in B[::-K]:
  ans += a
  if ans > 10**18:
    print('-1')
    break
else:
  print(ans)

Submission status: Wrong Answer

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

bag = []
bag_max = 0

for i in range(n):

    if i < k:
        bag.append(p[i])
        if bag_max < p[i]:
            bag_max = p[i]
    else:
        if bag_max > p[i]:
            bag.append(p[i])
            bag.remove(bag_max)
            bag_max = p[i]

print(sum(bag))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
asr = sorted(a)
del asr[0:n-k]
ans = sum(asr)
print(str(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

bag = []
bag_max = 0

for i in range(n):

    if i < k:
        bag.append(p[i])
        if bag_max < p[i]:
            bag_max = p[i]
    else:
        if bag_max > p[i]:
            bag.append(p[i])
            bag.remove(bag_max)
            bag_max = p[i]
    print(bag)

print(sum(bag))

Submission status: Wrong Answer

Solution code:
from sys import stdin

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

prices = sorted(prices)

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

Submission status: Wrong Answer

Solution code:
import heapq

n,k = map(int,input().split())
l1 = list(map(int,input().split()))
l2 = heapq.nsmallest(3, l1)
print(sum(l2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n , x = map(int,input().split())
price_list = list(map(int,input().split()))
ld = sorted(price_list, reverse=True)
sum = 0
for i in range(x):
  sum += ld[i]
print(sum)

Submission status: Wrong Answer

Solution code:
import heapq

N,K = input().split()
N = int(N)
K = int(K)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

[N,K]=map(int,input().split())
p=[""]*N
p=map(int,input().split())

px=sorted(p)
print(px)
total=0

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

print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b = [int(x) for x in input().split()]
cs = [int(x) for x in input().split()]
print(a, b)
print(cs)
cs.sort()

print(sum(cs[:b]))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
result = []
#初期リスト
for i in range(K):
    result.append(p[i])

for i in range(N-K,K):
    for j in range(K):
        if p[i] < result[j]:
            result[j] = p[i]
            break
print(sum(result))

Submission status: Wrong Answer

Solution code:
prices = []
total_fruits = 0
max_numb = 0

total_fruits, max_numb = input().split(' ')
tmp_prices = input().split(' ')
tmp_prices.sort()
ans = 0
for i in range(int(max_numb)):
  ans += int(tmp_prices[i])
  
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
if n>k:
    if k>1:
        s=p[0]+p[1]+p[2]
        print(s)
        exit()
        
if n==k:
    print(p[0])

Submission status: Wrong Answer

Solution code:
# encoding: utf-8
max_, request = map(int, input().split())
amounts = list(map(int, input().split()))
amounts.sort()
print(amounts[:request])

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split(' '))
fruit_prices = list(map(int, input().split(' ')))
print("{0}個の果物から{1}種類選ぶ".format(N, K))
print(fruit_prices)

fruit_prices.sort()
print(fruit_prices)

min_price = 0

for i in range(K):
  min_price += fruit_prices[i]

print(min_price)

Submission status: Wrong Answer

Solution code:
#n種類からk種類買う
n,k = map(int,input().split())
p = list(map(int,input().split()))
print(p)
#値段を昇順
p.sort()
#値段を足す
s = 0

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

print(s)

Submission status: Wrong Answer

Solution code:
import itertools
N, K = map(int, input().split())
P = list(map(int, input().split()))
B = list(itertools.combinations(P, K))
ans = 1001
if N == 1:
    print(P[0])
    exit(0)
for b in B:
    if ans > sum(b):
        ans = sum(b)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input().split()
intN = int(s[0])
intK = int(s[1])

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

#print(inList)
inList.sort()

#print(inList)

idx = 0
intCnt = 0

for wInt in inList:
    if (idx < 3) :
        intCnt += wInt
        #print(wInt) 
        #print(intCnt) 
    idx += 1

print(intCnt)

Submission status: Wrong Answer

Solution code:
import numpy as np
s = list(map(int,input().split()))
n=s[0]
k=s[1]
s = list(map(int, input().split()))
s.sort()
print(s)
s=np.array(s[0:k])
print(np.sum(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
l = map(int,input().split())
l = sorted(l)
print(l)
if(a<=b):
    print(sum(l))
else:
    print(sum(l[:b]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

if k < 3:
    print(sum(p))
    sys.exit()

p.sort()

print(p[0] + p[1] + p[2])

Submission status: Wrong Answer

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

Ans = sorted(P)[0:3:]
print(sum(Ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

if __name__ == "__main__":
  N, K = [int(a) for a in input().split()]
  P = list(map(int, input().split()))
  list.sort(P)
  print(P)
  ans = sum(P[:K])
  print(ans)

Submission status: Wrong Answer

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

L_2=sorted(L)

L_3=L_2[0:k]
print(L_3)
print(sum(L_3))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

res = 10**16
for i in range(N-K+1):
  res = min(res, sum(P[i:i+K]))

print(res)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())
l = map(int,input().split())
l = sorted(l)
print(sum(l[:3]))

Submission status: Wrong Answer

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

p.sort

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import itertools

N, K = map(int, input().split())
A = input().split()
L = [int(b.strip()) for b in A]  

#print(N)
#print(K)
#print(L)

ret = 1000
for v in itertools.combinations(L, 3):
    #print(v)
    s = sum(v)
    #print(s)
    if ret > s:
      ret = s

print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
if k>1:
    s=p[0]+p[1]+p[2]
    print(s)
else:
    print(p[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-06-21 20:42:23 +0900
# LastModified: 2020-06-21 21:09:42 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

cumsum = [0]
for p in P:
  cumsum.append(cumsum[-1]+p)

res = 10**15
for i in range(N-K+1):
  res = min(res, cumsum[i+K]-cumsum[i])

print(res)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
s = list(map(int,input().split()))
a = 0
for b in s:
    a = a + b
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
if len(p) >= 3:
    print(p[0]+p[1]+p[2])
elif len(p) == 2:
    print(p[0] + p[1])
else:
    print(p[0])

Submission status: Wrong Answer

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

    print(p)
    p.sort()
    print(p)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

p.sort()

sum=0
count=0

for i in range(N):
    sum+=p[i]
    count+=1
    if count==3:
        break
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n = 0
for i in range(b):
  n += i
  
print(n)

Submission status: Wrong Answer

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

c = itertools.combinations(p, K)
ans = 10**5
for i in c:
    ans = min(ans, sum(i))
print(ans)

Submission status: Wrong Answer

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

p = sorted(p)

print(sum(p[:N]))

Submission status: Wrong Answer

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

p.sort()

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

    print(ans)

Submission status: Wrong Answer

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

p = sorted(p)
ans = 0

for a in p[:K]:
    ans += a
    print(a)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
p=[int(i) for i in input().split()]
p.sort()
if len(p)==1:
    print(p[0])
elif len(p)==2:
    print(p[0]+p[1])
else:
    print(p[0]+p[1]+p[2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(sum)

Submission status: Wrong Answer

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

price_list.sort()

print(price_list)
print(sum(price_list[:k]))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ps.sort()
ps[0:3]
print(sum(ps[0:3]))

Submission status: Wrong Answer

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

print(sum(p))

Submission status: Wrong Answer

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

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

print(sum(P[:K]))

Submission status: Wrong Answer

Solution code:
n, k =map(int, input().split())  #複数数値入力
list_p=list(map(int, input().split()))  #リスト入力

list_p.sort()

sum(list_p[:k])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

p.sort()

print(sum(p[:3]))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(v) for v in input().split()]
print(sum(a[:k]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

p = sorted(p)

print(p)

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]
a = [int(i) for i in input().split()]
sorted(a)
sum = 0
for i in range(m):
  sum += a[i]
print(sum)

Submission status: Wrong Answer

Solution code:
n,k = map(int ,raw_input().split(' '))
prices = map(int, raw_input().split(' '))

print sum(prices[:k])

Submission status: Wrong Answer

Solution code:
x=input()
if x.isupper()==True:
    print("A")
else:
    print("a")

Submission status: Wrong Answer

Solution code:
#! -*- coding: utf-8 -*-
n, k = map(int, input().split())
price = list(map(int, input().split()))
sorted_price = sorted(price)

print(sum(sorted_price[0:3]))

Submission status: Wrong Answer

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

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

print(sum(a[:3]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(sum(list_[:k]))

Submission status: Wrong Answer

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

    p.sort()

    print(sum(p[:3]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

p_L = list(sorted(p_L))
print(sum(p_L[:3]))

Submission status: Wrong Answer

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

pp = sorted(map(int, input().split()), reverse=True)

print(sum(pp[:k]))

Submission status: Wrong Answer

Solution code:
def main():
    n,k = map(int,input().split())
    p = list(map(int,input().split()))
    p.sort()
    print(sum(p[:3]))
if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    return sum(P)

print(main())
#print('Yes' if main() else 'No')
#print('YES' if main() else 'NO')

Submission status: Time Limit Exceeded

Solution code:
import itertools
[N, K] = [int(i)  for i in input().split()]
price = [int(i)  for i in input().split()]
select_sum = sum(price)
for select  in itertools.combinations(price, K):
    if sum(select) < select_sum:
        select_sum = sum(select)
print(select_sum)

Submission status: Time Limit Exceeded

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

ans = float('inf')

for buy_list in list(combinations(P, K)):
    ans_ = 0
    for buy in buy_list:
        ans_ += buy
    ans = min(ans, ans_)
    
print(ans)