#include <iostream>
#include <vector>
#include <algorithm> using namespace std; int main(){
int n,d;
cin >> n >>d;
vector<int>a(n);
for(int i = ; i < n ; ++ i )
cin >>a[i];
int m;
cin >> m;
sort(a.begin(),a.end());
int sum = ;
if(m <=n){
for(int i = ; i < m; ++ i)
sum+=a[i];
}
else{
for(int i = ; i < n; ++ i)
sum+=a[i];
sum -= d*(m-n);
}
cout<<sum<<endl;
return ;
}

Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack的更多相关文章

  1. Codeforces Round #215 (Div. 2) B. Sereja and Suffixes map

    B. Sereja and Suffixes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...

  2. Codeforces Round #215 (Div. 1) B. Sereja ans Anagrams 匹配

    B. Sereja ans Anagrams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...

  3. Codeforces Round #215 (Div. 2) D. Sereja ans Anagrams

    http://codeforces.com/contest/368/problem/D 题意:有a.b两个数组,a数组有n个数,b数组有m个数,现在给出一个p,要你找出所有的位置q,使得位置q  q+ ...

  4. Codeforces Round #215 (Div. 2) C. Sereja and Algorithm

    #include <iostream> #include <vector> #include <algorithm> #include <string> ...

  5. Codeforces Round #215 (Div. 2) B. Sereja and Suffixes

    #include <iostream> #include <vector> #include <algorithm> #include <set> us ...

  6. Codeforces Round #223 (Div. 2) E. Sereja and Brackets 线段树区间合并

    题目链接:http://codeforces.com/contest/381/problem/E  E. Sereja and Brackets time limit per test 1 secon ...

  7. Codeforces Round #215 (Div. 2) D题(离散化+hash)

    D. Sereja ans Anagrams time limit per test 1 second memory limit per test 256 megabytes input standa ...

  8. Codeforces Round #215 (Div. 1)

    A Sereja and Algorithm 题意:给定有x,y,z组成的字符串,每次询问某一段s[l, r]能否变成变成zyxzyx的循环体. 分析: 分析每一段x,y,z数目是否满足构成循环体,当 ...

  9. Codeforces Round #223 (Div. 2)--A. Sereja and Dima

    Sereja and Dima time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

随机推荐

  1. SQLServer操作结果集

    union组合结果集 --相同合并 union --全部显示 union all 公用表表达式 with CET( wName,dName) as ( select wName,dName from ...

  2. 微信公众平台中的openid是什么?

    在微信公众平台开发中,会遇到一个叫openid的东东,让我们这些不懂开发的摸不着头脑,开始我也是一头雾水,经过多方面查资料,终于明白是怎么回事了! openid是公众号的普通用户的一个唯一的标识,只针 ...

  3. Delphi的枚举类型

    参考:http://blog.csdn.net/kissdeath/article/details/2060573 Delphi程序不仅可以用于数值处理,还更广泛的用于处理非数值的数据.例如:性别.月 ...

  4. ASP.NET多线程下使用HttpContext.Current为null解决方案 2015-01-22 15:23 350人阅读 评论(0) 收藏

    问题一:多线程下获取文件绝对路径 当我们使用HttpContext.Current.Server.MapPath(strPath)获取绝对路径时HttpContext.Current为null,解决办 ...

  5. Oracle 10g Block Change Tracking特性

    Using Block Change Tracking to Improve Incremental Backup Performance 使用块改变跟踪改善增量备份的性能 The block cha ...

  6. 分佈式事務故障處理暨ORA-24756: transaction does not exist處理

    ORA-24756处理 看到警告日誌一直報ORA-24756錯誤 Errors in file /oracle/admin/NHMIX01/bdump/nhmix01_reco_4959.trc: O ...

  7. js onclick="return test()"事件返回值,对有些事件,会影响默认动作的执行。如:onclick和onsubmit

    onclick="return test()"事件返回值,对有些事件,会影响默认动作的执行.如:onclick和onsubmit <body> <!--事件返回值 ...

  8. apistore接口调用demo

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. php几个常用的概率算法(抽奖、广告首选)

    做网站类的有时会弄个活动什么的,来让用户参加,既吸引用户注册,又提高网站的用户活跃度.同时参加的用户会获得一定的奖品,有100%中奖的,也有按一定概率中奖的,大的比如中个ipad.iphone5,小的 ...

  10. DNX/ASP.NET 5的xUnit入门向导

    (此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:想必很多人已经和我一样在使用ASP.NET 5开发真实世界的应用了,那么做好单元测试和 ...