Description

The marmots have prepared a very easy problem for this year's HC2 – this one. It involves numbers nk and a sequence of n positive integersa1, a2, ..., an. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output, and it also reads like a good criminal.

However I, Heidi, will have none of that. As my joke for today, I am removing the story from the statement and replacing it with these two unhelpful paragraphs. Now solve the problem, fools!

Input

The first line of the input contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 2200). The second line contains n space-separated integers a1, ..., an (1 ≤ ai≤ 104).

Output

Output one number.

Examples
input
8 5
1 1 1 1 1 1 1 1
output
5
input
10 3
16 8 2 4 512 256 32 128 64 1
output
7
input
5 1
20 10 50 30 46
output
10
input
6 6
6 6 6 6 6 6
output
36
input
1 1
100
output
100
题意:额。。。就是选k个数字(从小到大加起来啦)
解法:同上
#include<bits/stdc++.h>
using namespace std;
long long sum;
int t;
int k,n;
int x[];
int main()
{
cin>>n>>k;
for(int i=;i<=n;i++)
{
cin>>x[i];
}
sort(x+,x++n);
for(int i=;i<=k;i++)
{
sum+=x[i];
}
cout<<sum<<endl;
return ;
}

最新文章

  1. Spring_的jar详细说明
  2. mount: /dev/sdb1 already mounted or /mnt/hdb busy 导致NameNode无法启动
  3. filter应用案例四:页面静态化
  4. sql server数据库语句
  5. npm ERR!无法安装任何包的解决办法
  6. mysql mysqldump只导出表结构或只导出数据的实现方法
  7. careercup-树与图 4.8
  8. HTML&amp;CSS基础学习笔记1.28-给网页添加一个css样式
  9. Long,String类型的两个值进行比较,注意点!!!
  10. KMP原理、分析及C语言实现
  11. 链表c语言实现
  12. 浅谈关于特征选择算法与Relief的实现
  13. javaScript识别网址文本并转为链接文本
  14. HTML 5核心内容
  15. React踩坑记
  16. Android greenDAO 数据库 简单学习之基本使用
  17. HTML元素的分类
  18. Python全栈开发之路 【第十六篇】:jQuey的动画效果、属性操作、文档操作、input的value
  19. 【Python3练习题 013】 求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字
  20. 三十七、Linux 线程——线程清理和控制函数、进程和线程启动方式比较、线程的状态转换

热门文章

  1. MapReduce简述、工作流程及新旧API对照
  2. leetcode笔记:Pascal&amp;#39;s Triangle
  3. 1449: [JSOI2009]球队收益
  4. Java多态性详解 (父类引用子类对象)
  5. A Practical Introduction to Blockchain with Python
  6. 阿里Java编程规范 学习笔记
  7. 根据查询出各地订单商品数量 group by
  8. 关于static和const
  9. 基于Python 的简单推荐系统
  10. 织梦dedecms如何显示所有文章列表