题目传送门

  1. /*
  2. 贪心:每次把一个丢掉,选择最小的。累加求和,重复n-1次
  3. */
  4. /************************************************
  5. Author :Running_Time
  6. Created Time :2015-8-1 13:20:01
  7. File Name :A.cpp
  8. *************************************************/
  9. #include <cstdio>
  10. #include <algorithm>
  11. #include <iostream>
  12. #include <sstream>
  13. #include <cstring>
  14. #include <cmath>
  15. #include <string>
  16. #include <vector>
  17. #include <queue>
  18. #include <deque>
  19. #include <stack>
  20. #include <list>
  21. #include <map>
  22. #include <set>
  23. #include <bitset>
  24. #include <cstdlib>
  25. #include <ctime>
  26. using namespace std;
  27. typedef long long ll;
  28. const int MAXN = 3e5 + ;
  29. const int INF = 0x3f3f3f3f;
  30. const int MOD = 1e9 + ;
  31. int a[MAXN];
  32. int main(void) { //Codeforces Round #263 (Div. 2) C. Appleman and Toastman
  33. int n; ll sum, ans;
  34. while (scanf ("%d", &n) == ) {
  35. sum = ;
  36. for (int i=; i<=n; ++i) {
  37. scanf ("%d", &a[i]); sum += a[i];
  38. }
  39. if (n == ) {
  40. printf ("%d\n", a[]); continue;
  41. }
  42. sort (a+, a++n);
  43. ans = sum;
  44. for (int i=; i<n; ++i) {
  45. ans += sum; sum -= a[i];
  46. }
  47. printf ("%I64d\n", ans);
  48. }
  49. return ;
  50. }

贪心 Codeforces Round #263 (Div. 2) C. Appleman and Toastman的更多相关文章

  1. Codeforces Round #263 (Div. 2) D. Appleman and Tree(树形DP)

    题目链接 D. Appleman and Tree time limit per test :2 seconds memory limit per test: 256 megabytes input ...

  2. Codeforces Round #263 (Div. 1) C. Appleman and a Sheet of Paper 树状数组暴力更新

    C. Appleman and a Sheet of Paper   Appleman has a very big sheet of paper. This sheet has a form of ...

  3. Codeforces Round #263 (Div. 2) A. Appleman and Easy Task【地图型搜索/判断一个点四周‘o’的个数的奇偶】

    A. Appleman and Easy Task time limit per test 1 second memory limit per test 256 megabytes input sta ...

  4. Codeforces Round #263 Div.1 B Appleman and Tree --树形DP【转】

    题意:给了一棵树以及每个节点的颜色,1代表黑,0代表白,求将这棵树拆成k棵树,使得每棵树恰好有一个黑色节点的方法数 解法:树形DP问题.定义: dp[u][0]表示以u为根的子树对父亲的贡献为0 dp ...

  5. 贪心 Codeforces Round #288 (Div. 2) B. Anton and currency you all know

    题目传送门 /* 题意:从前面找一个数字和末尾数字调换使得变成偶数且为最大 贪心:考虑两种情况:1. 有偶数且比末尾数字大(flag标记):2. 有偶数但都比末尾数字小(x位置标记) 仿照别人写的,再 ...

  6. 贪心 Codeforces Round #301 (Div. 2) B. School Marks

    题目传送门 /* 贪心:首先要注意,y是中位数的要求:先把其他的都设置为1,那么最多有(n-1)/2个比y小的,cnt记录比y小的个数 num1是输出的1的个数,numy是除此之外的数都为y,此时的n ...

  7. 贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks

    题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio ...

  8. 贪心 Codeforces Round #304 (Div. 2) B. Soldier and Badges

    题目传送门 /* 题意:问最少增加多少值使变成递增序列 贪心:排序后,每一个值改为前一个值+1,有可能a[i-1] = a[i] + 1,所以要 >= */ #include <cstdi ...

  9. 贪心 Codeforces Round #303 (Div. 2) B. Equidistant String

    题目传送门 /* 题意:找到一个字符串p,使得它和s,t的不同的总个数相同 贪心:假设p与s相同,奇偶变换赋值,当是偶数,则有答案 */ #include <cstdio> #includ ...

随机推荐

  1. 守卫者的挑战(codevs 1997)

    题目描述 Description 打开了黑魔法师Vani的大门,队员们在迷宫般的路上漫无目的地搜寻着关押applepi的监狱的所在地.突然,眼前一道亮光闪过.“我,Nizem,是黑魔法圣殿的守卫者.如 ...

  2. Linux下汇编语言学习笔记63 ---

    这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...

  3. POJ 3233_Matrix Power Series

    题意: 求n*n矩阵的幂和 分析: 逐个加起来时间复杂度太高,通过在矩阵中套个矩阵和,再利用矩阵快速幂,最后时间复杂度为O(n3logn) 代码: #include<cstdio> #in ...

  4. hadoop(1)入门

    hadoop入门(一)   一.概述 1.什么是hadoop hadoop不仅是一个用于存储分布式文件系统,还是设计用来在有通用计算设备组成的大型集群上执行的分布式应用的基础框架. hadoop框架最 ...

  5. oracle常用函数积累

    --oracle常用函数积累-- --1.字符串长度:LENGTH ,语法: CONCAT(string) --示例 select LENGTH('AA_BB') from dual;--结果:5 - ...

  6. Samba.conf案例 Ubuntu

    # Sample configuration file for the Samba suite for Debian GNU/Linux.## This is the main Samba confi ...

  7. {head first} --- networking 1

    Head first系列的书确实非常好,深入浅出解说网络的组成.让曾经那些生涩的概念生动起来. Chapter 1 维修物理网络 CAT5电缆: 两端为RJ-45接头(水晶头).内部为UTP(非屏蔽双 ...

  8. android意图传參数(四)

    一.依照向导创建一个project,layout的activity_main.xml文件内容例如以下: <RelativeLayout xmlns:android="http://sc ...

  9. 高速清空linux下文本文件内容

    1.[root@desktop huage]# : > filename :是一个占位符.不会产生不论什么输入   2.[root@desktop huage]# > filename 相 ...

  10. java web中的session属性范围和request属性范围

    首先必需要了解client跳转和server端跳转的差别: client跳转: response.sendRedict(String path).地址栏发生改变. 不能传递request属性. ser ...