Codeforces 368A Sereja and Coat Rack(模拟)
来源:互联网 发布:自学软件测试靠谱吗 编辑:程序博客网 时间:2024/05/19 11:37
题目链接:Codeforces 368A Sereja and Coat Rack
直接模拟,简单题。
#include <iostream>#include <algorithm>using namespace std;const int MAX_N = 100 + 10;int a[MAX_N];int n,d,m;int main(){ int sum = 0; cin >> n >> d; for(int i = 1;i <= n;i++) { cin >> a[i]; sum += a[i]; } sort(a + 1,a + n + 1); cin >> m; if(n == m) cout << sum << endl; else if(m > n) cout << sum - (m - n) * d << endl; else { sum = 0; for(int i = 1;i <= m;i++) sum += a[i]; cout << sum << endl; } return 0;}
0 0
- Codeforces 368A Sereja and Coat Rack(模拟)
- CodeForces 368A Sereja and Coat Rack
- CodeForces - 368A Sereja and Coat Rack (水)
- CodeForces 368A-Sereja and Coat Rack【队列】
- CodeForces 368A:Sereja and Coat Rack【水】
- A. Sereja and Coat Rack
- Codeforces 215A A.Sereja and Coat Rack
- Codeforces Round #215 (Div. 2) -A. Sereja and Coat Rack
- Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack
- I - Sereja and Coat Rack
- CF#215DIV2:A. Sereja and Coat Rack
- codeforce Sereja and Coat Rack(简单排序)
- CodeForces 368B-Sereja and Suffixes【模拟】
- Codeforces 381A Sereja and Dima(模拟)
- Codeforces 380A Sereja and Prefixes(模拟)
- A. Sereja and Prefixes----模拟
- codeforces --A - Sereja and Algorithm
- CodeForces - 368C Sereja and Algorithm (找规律&模拟)
- 黑马程序员 java中覆盖、重写与重载的区别
- hdu1864 最大报销额
- 直接插入排序---java实现
- P2P流量识别技术汇总(原理、优缺点介绍)
- HDU1160——FatMouse's Speed(DP入门)
- Codeforces 368A Sereja and Coat Rack(模拟)
- 二叉树最近公共祖先(LCA)
- 形参、局部(非静态)变量和静态局部变量的差别
- Android下载文件到sd card的一些常见问题
- java 线程通信
- 第五周项目1-三角形类的构造函数(3)
- PL/SQL_触发器4(建立INSTEAD OF触发器)
- 基本招式--单例模式
- QueryMobile + PhoneGap 经验总结