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 ;
}
Helvetic Coding Contest 2017 online mirror (teams allowed, unrated) M的更多相关文章
- Helvetic Coding Contest 2017 online mirror (teams allowed, unrated)
G. Fake News (easy) time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Helvetic Coding Contest 2017 online mirror (teams allowed, unrated) J
Description Heidi's friend Jenny is asking Heidi to deliver an important letter to one of their comm ...
- Helvetic Coding Contest 2017 online mirror (teams allowed, unrated) A
Description Your search for Heidi is over – you finally found her at a library, dressed up as a huma ...
- Helvetic Coding Contest 2019 online mirror (teams allowed, unrated)
http://codeforces.com/contest/1184 A1 找一对整数,使x^x+2xy+x+1=r 变换成一个分式,保证整除 #include<iostream> #in ...
- Helvetic Coding Contest 2018 online mirror (teams allowed, unrated)F3 - Lightsabers (hard)
题意:n个数字1-m,问取k个组成的set方案数 题解:假设某个数出现k次,那么生成函数为\(1+x+...+x^k\),那么假设第i个数出现ai次,结果就是\(\sum_{i=1}^m(1+x+.. ...
- CF 690C3. Brain Network (hard) from Helvetic Coding Contest 2016 online mirror (teams, unrated)
题目描述 Brain Network (hard) 这个问题就是给出一个不断加边的树,保证每一次加边之后都只有一个连通块(每一次连的点都是之前出现过的),问每一次加边之后树的直径. 算法 每一次增加一 ...
- [Helvetic Coding Contest 2017 online mirror]
来自FallDream的博客,未经允许,请勿转载,谢谢, 第一次在cf上打acm...和同校大佬组队打 总共15题,比较鬼畜,最后勉强过了10题. AB一样的题目,不同数据范围,一起讲吧 你有一个背包 ...
- 【Codeforces】Helvetic Coding Contest 2017 online mirror比赛记
第一次打ACM赛制的团队赛,感觉还行: 好吧主要是切水题: 开场先挑着做五道EASY,他们分给我D题,woc什么玩意,还泊松分布,我连题都读不懂好吗! 果断弃掉了,换了M和J,然后切掉了,看N题: l ...
- Helvetic Coding Contest 2016 online mirror A1
Description Tonight is brain dinner night and all zombies will gather together to scarf down some de ...
随机推荐
- Mysql整数运算NULL值处理注意点
CleverCode近期在导出报表的时候,在整数做减法的时候,发现整数减去null得到是null.这是一个细节问题,希望大家以后注意. 1 表中的数据 total,used都是整形,同意为空. 2 有 ...
- Python2.7安装教程
作者:zhanhailiang 日期:2014-11-16 [root@~/software]# yum install bzip* [root@~/software]# wget http://ww ...
- redis08----集群
集群的作用: .主从备份,防止主机宕机 .读写分离,主服务器写,从服务器内容跟着主服务器,主服务器变他就变,读就从从服务器读.减轻主服务器的负担. .任务分离,比如消耗cpu和内存的操作,交给从服务器 ...
- vue 中的组件通信
vue中组件通信,一般分为三种情况,父与子,子与父,子子之间. 一.父与子通信 父组件将值传给子组件,一般通过props,设置默认的类型.调用的时候通过 xx=" ", 或者:XX ...
- js截取小数点后面2位
1.substr var str = "Hello world!"; document.write(str.substr(3)); 输出:lo world! var str = & ...
- jsp的4大作用域
jsp的4大作用域 首先要声明一点,所谓“作用域”就是“信息共享的范围”,也就是说一个信息能够在多大的范围内有效.4个JSP内置对象的作用域分别为:application.session.reques ...
- Java中的ArrayList
ArrayList是所谓的动态数组.用一个小例子: import java.util.ArrayList; import java.util.Iterator; import java.util.Li ...
- CodeForces546D:Soldier and Number Game(筛区间素数因子个数和)
Two soldiers are playing a game. At the beginning first of them chooses a positive integer n and giv ...
- 「咕咕网校 - 基础省选」树上问题的进阶 by Drench
一定要在noip之前把自己花钱买的Luogu网课梳理完!QAQ 树上前缀和: 对于有根树,在每个点记录 val (点权) 和 sum(到根的点权之和) 当然记录的值因题而异(但是既然叫树上前缀和当然就 ...
- Superprime Rib
链接 分析:满足题目条件的必然是1,2,3,5,7,9这几个数字的组合,DFS按位进行即可,边组合边判断是否合法. /* PROB:sprime ID:wanghan LANG:C++ */ #inc ...