Helvetic Coding Contest 2017 online mirror (teams allowed, unrated) M
Description
The marmots have prepared a very easy problem for this year's HC2 – this one. It involves numbers n, k 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!
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 one number.
8 5
1 1 1 1 1 1 1 1
5
10 3
16 8 2 4 512 256 32 128 64 1
7
5 1
20 10 50 30 46
10
6 6
6 6 6 6 6 6
36
1 1
100
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 ;
}
最新文章
- Spring_的jar详细说明
- mount: /dev/sdb1 already mounted or /mnt/hdb busy 导致NameNode无法启动
- filter应用案例四:页面静态化
- sql server数据库语句
- npm ERR!无法安装任何包的解决办法
- mysql mysqldump只导出表结构或只导出数据的实现方法
- careercup-树与图 4.8
- HTML&;CSS基础学习笔记1.28-给网页添加一个css样式
- Long,String类型的两个值进行比较,注意点!!!
- KMP原理、分析及C语言实现
- 链表c语言实现
- 浅谈关于特征选择算法与Relief的实现
- javaScript识别网址文本并转为链接文本
- HTML 5核心内容
- React踩坑记
- Android greenDAO 数据库 简单学习之基本使用
- HTML元素的分类
- Python全栈开发之路 【第十六篇】:jQuey的动画效果、属性操作、文档操作、input的value
- 【Python3练习题 013】 求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字
- 三十七、Linux 线程——线程清理和控制函数、进程和线程启动方式比较、线程的状态转换