题目传送门

 /*
贪心:每次把一个丢掉,选择最小的。累加求和,重复n-1次
*/
/************************************************
Author :Running_Time
Created Time :2015-8-1 13:20:01
File Name :A.cpp
*************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; typedef long long ll;
const int MAXN = 3e5 + ;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + ;
int a[MAXN]; int main(void) { //Codeforces Round #263 (Div. 2) C. Appleman and Toastman
int n; ll sum, ans;
while (scanf ("%d", &n) == ) {
sum = ;
for (int i=; i<=n; ++i) {
scanf ("%d", &a[i]); sum += a[i];
}
if (n == ) {
printf ("%d\n", a[]); continue;
}
sort (a+, a++n);
ans = sum;
for (int i=; i<n; ++i) {
ans += sum; sum -= a[i];
}
printf ("%I64d\n", ans);
} return ;
}

贪心 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. java中使用Protobuf的实例(Demo)

    由于Protobuf受到推崇,故尝试采用protobuf来摒弃传统的xml进行传输数据. 首先,需要下载的关于Protobuf的文件: 1.到http://code.google.com/p/prot ...

  2. 使用GSON解析JSON文件

    package com.pingyijinren.test; /** * Created by Administrator on 2016/5/19 0019. */ public class App ...

  3. javaweb开发页面数字过长显示科学计数法的问题

    1. 检查该字段是否为double类型,如果是,请改成BigDecimal 2.如果是导出excel里面为科学计数法,原页面正常,是因为excel设置的原因,请参考https://jingyan.ba ...

  4. Ubuntu 16.04出现chmod: 无效模式:"a"的问题解决

    命令: chmod a+x file1 提示:注意文件的类型,如果用在文件夹上是不行的,但是文件确实可以的.

  5. Nginx/Spring:增加上传文件尺寸限制

    Nginx: 1. vi /etc/nginx/nginx.config 2. 在server中增加如下行 # set client body size to 20M # client_max_bod ...

  6. 在gentoo中打开tomcat的远程调试开关

    在一般象gentoo等发行版中,系统安装tomcat这类软件后会产生一些启动脚本, 比如是/etc/init.d/tomcat-7, 启动方式与原始的tomcat不太一样.在gentoo中,假设须要远 ...

  7. hadoop 文件操作

    Create a directory in HDFS - mkdir The hadoop mkdir command is for creating directories in the hdfs. ...

  8. MySql command line client 命令系列

    —————————————————————————————————————————————————————————— 一.启动与退出 1.进入MySQL:启动MySQL Command Line Cl ...

  9. HDU Today HDU杭电2112【Dijkstra || SPFA】

    http://acm.hdu.edu.cn/showproblem.php?pid=2112 Problem Description 经过锦囊相助,海东集团最终度过了危机,从此.HDU的发展就一直顺风 ...

  10. Android学习笔记-tween动画之xml实现

    继上篇tween动画的java实现:http://www.cnblogs.com/fengtengfei/p/3957800.html, 这里我接着介绍一下tween动画的xml实现的方法,   首先 ...