Codeforces 461A Appleman and Toastman(贪心)
来源:互联网 发布:x软件下载 编辑:程序博客网 时间:2024/06/04 17:41
题目链接:Codeforces 461A Appleman and Toastman
题目大意:给定一个集合,每次由A将集合交个B,然后B计算集合中元素的总和,加到得分中,将集合还给A,然后A将集合随机分成两个集合,然后逐个给B,B进行相同的操作,直到集合中元素个数为1时,A不拆分集合,而是直接舍弃。问说最大得分。
解题思路:贪心,每次从集合中剔除值最小的即可。
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;const int maxn = 3 * 1e5 + 5;int N, arr[maxn];int main () { scanf("%d", &N); ll sum = 0; for (int i = 1; i <= N; i++) { scanf("%d", &arr[i]); sum += arr[i]; } sort(arr + 1, arr + 1 + N); ll ans = sum; for (int i = 1; i < N; i++) { ans += sum; sum -= arr[i]; } printf("%lld\n", ans); return 0;}
0 0
- Codeforces 461A Appleman and Toastman(贪心)
- CodeForces 461A Appleman and Toastman(贪心)
- Codeforces-461A Appleman and Toastman
- Appleman and Toastman - CodeForces 461 A 水题
- Codeforces 461A Appleman and Toastman
- codeforces 461A Appleman and Toastman
- 【codeforces】 461A Appleman and Toastman
- CodeForces 461A Appleman and Toastman
- CodeForces 461A Appleman and Toastman
- codeforces 461A Appleman and Toastman
- 461A - Appleman and Toastman
- CodeForces 462C Appleman and Toastman 贪心
- A. Appleman and Toastman(codeforces#263div1)
- A. Appleman and Toastman
- CF 461 A Appleman and Toastman
- Codeforces461A Appleman and Toastman 贪心
- Codeforces 462C C. Appleman and Toastman【贪心】
- 【CODEFORCES】 C. Appleman and Toastman
- hdu 4848 搜索+剪枝 2014西安邀请赛
- textFieldShouldReturn方法的使用
- Oracle数据库备份
- 大数据查询
- 有哪些被后人曲解的古文或古诗词?
- Codeforces 461A Appleman and Toastman(贪心)
- UVM::config
- MFC多线程的创建,包括工作线程和用户界面线程
- CSS中的框模型(box model)/margin、padding、border介绍/ 外边距层叠collapsing计算
- Linux下PSUADE安装全过程(CentOS6.4——RPMforge——cmake、ccmake——PAUADE)
- 怎样在Eclipse Java EE编译器中修改Web项目的发布名称
- 最后一次开学
- php持续集成环境笔记
- ContentProvider,Cursor,CursorAdapter之间的关系图。