CodeForces-462C Appleman and Toastman
来源:互联网 发布:nagios windows客户端 编辑:程序博客网 时间:2024/06/05 07:49
#include <iostream>#include <algorithm>#include <cstdio>using namespace std;const int maxn = 3e5 + 5;long long num[maxn];long long sum, ans;int n;int main(){ while(~scanf("%d", & n)) { sum = 0; for(int i = 0; i < n; i ++) scanf("%I64d", & num[i]); sort(num, num + n); for(int i = 0; i < n; i ++) sum += num[i]; ans = sum; for(int i = 0; i < n - 1; i ++) { ans += sum; sum -= num[i]; } printf("%I64d\n", ans); } return 0;}
题意:输入n。算总和先。之后每次去一个数(要加在总和) 继续加在总和中。直到最后只有2个元素。
题解:水题。随意玩。ans记得用long long..cin 和 scanf 输入时间差很多..
0 0
- CodeForces-462C Appleman and Toastman
- CodeForces 462C Appleman and Toastman 贪心
- 【CODEFORCES】 C. Appleman and Toastman
- 462C - Appleman and Toastman
- Codeforces 462C C. Appleman and Toastman【贪心】
- Codeforces Round #263 (Div. 2)C. Appleman and Toastman
- Codeforces Round #263(div2)C. Appleman and Toastman
- Codeforces Round #263 (Div. 2) C. Appleman and Toastman
- Codeforces Round #263 (Div. 2)-C. Appleman and Toastman
- Codeforces Round #263 (Div. 2)-C. Appleman and Toastman
- Codeforces-461A Appleman and Toastman
- Appleman and Toastman - CodeForces 461 A 水题
- Codeforces 461A Appleman and Toastman
- A. Appleman and Toastman(codeforces#263div1)
- Codeforces 461A Appleman and Toastman(贪心)
- codeforces 461A Appleman and Toastman
- 【codeforces】 461A Appleman and Toastman
- CodeForces 461A Appleman and Toastman(贪心)
- 阶乘的素因子分解 51nod 1189
- swift学习之关键字inout
- 小白安卓开发学习记1-开发环境(Eclicape)的配置
- HDU 4334 Trouble(hash + 枚举)
- CSS优先级与继承
- CodeForces-462C Appleman and Toastman
- 数据库优化-基准测试(五)
- 软件项目投标文件的注意事项
- POJ 3207 Ikki's Story IV - Panda's Trick(2-SAT)
- 千万数量级分页存储过程代码
- 堆排序(C语言实现)
- Leetcode Majority Element系列 摩尔投票法
- [IOS] The difference between functions and methods
- Android核心基础-7.Android 网络通信-6.访问Webservice