1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8. int n,d;
  9. cin >> n >>d;
  10. vector<int>a(n);
  11. for(int i = ; i < n ; ++ i )
  12. cin >>a[i];
  13. int m;
  14. cin >> m;
  15. sort(a.begin(),a.end());
  16. int sum = ;
  17. if(m <=n){
  18. for(int i = ; i < m; ++ i)
  19. sum+=a[i];
  20. }
  21. else{
  22. for(int i = ; i < n; ++ i)
  23. sum+=a[i];
  24. sum -= d*(m-n);
  25. }
  26. cout<<sum<<endl;
  27. return ;
  28. }

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. samba 报错

    [root@GitLab data_nfs]# smbclient //localhost/public WARNING: The security=share option is deprecate ...

  2. Jquery.Datatables dom表格定位

    Datatables会添加一些控制元素在表格的周围,比如默认状态下改变每页显示条数(l)的空间在左上角,即使搜索框(f)在右上角,表格的信息(i)显示在左下角,分页控件(p)显示在右下角. 这些控件在 ...

  3. 【翻译四】java-并发之线程暂停

    Pausing Execution with Sleep Thread.sleep causes the current thread to suspend execution for a speci ...

  4. java中常用的工具类(三)

    继续分享java中常用的一些工具类.前两篇的文章中有人评论使用Apache 的lang包和IO包,或者Google的Guava库.后续的我会加上的!谢谢支持IT江湖 一.连接数据库的综合类       ...

  5. sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)

    Rescue The Princess Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Several days ago, a b ...

  6. java.lang.UnsupportedClassVersionError: org/xwiki/xxx : Unsupported major.minor version 51.0

    此类问题主要是因为Unsupported major.minor version 51.0. 原因是JDK版本不一致导致的问题.在web应用中碰到此问题. 应用中规定使用JDK7.0,本地JDK为6. ...

  7. Oracle merge

    oracle merge 語法:

  8. phpcms v9 wap内容页内容显示方法

    phpcms v9的wap手机门户的问题解决 默认的{$content}标签假如内容页一开始输入的不是html代码的话会出现调用不出来的情况,这里用{$rs['content']} 来调用则可以解决问 ...

  9. Sp EF输出 临时表

    -- ============================================= -- Author: <Author,,Name> -- Create date: < ...

  10. Linux学习笔记(5)Linux常用命令之文件搜索命令

    (1)find find命令用于文件搜索,所在路径/bin/find,其语法格式为: find [搜索范围] [匹配条件] 1)-name:根据文件名搜索,如搜索/etc下的init文件 [root@ ...