Nội dung Bài tập
Mã:
ABC171.BaiB
Tên:
ABC171.BaiB
Dạng thi:
oi
Thang điểm:
100 điểm
Giới hạn thời gian:
1 giây
Giới hạn bộ nhớ:
256 MB
Được tạo bởi:
admin

Problem Statement

A shop sells N kinds of fruits, Fruit 1,,N, at prices of p1,,pN 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

  • 1KN1000
  • 1pi1000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
p1 p2  pN

Output

Print an integer representing the minimum possible total price of fruits.


Sample Input 1 Copy

Copy
5 3
50 100 80 120 80

Sample Output 1 Copy

Copy
210

This shop sells Fruit 1234, 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 13, and 5.


Sample Input 2 Copy

Copy
1 1
1000

Sample Output 2 Copy

Copy
1000

    Quảng cáo
       Ngôn ngữ : 

       Theme : 
Mời bạn soạn code



		



      Ai có thể xem bài này : 

Thông tin



Phần thảo luận