题目传送门

 /*
贪心:每次把一个丢掉,选择最小的。累加求和,重复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. Multiprocessing system employing pending tags to maintain cache coherence

    A pending tag system and method to maintain data coherence in a processing node during pending trans ...

  2. vagrant的学习 之 ThinkPHP5.1

    vagrant的学习 之 ThinkPHP5.1 本文根据慕课网的视频教程练习,感谢慕课网! 慕课视频学习地址:https://www.imooc.com/video/14218. 慕课的参考文档地址 ...

  3. Ajax核心知识(2)

    对于Ajax核心的东西需要在进行总结提炼一下: xmlHttp对象. 方法:xml.responseText获取后台传递到前台的数据,经常性的使用var object=xml.responseText ...

  4. LOAP& its implimenlation

    LDAP 概念 LDAP的英文全称是Lightweight Directory Access Protocol,简称为LDAP,LDAP是轻量目录访问协议,LDAP是轻量目录访问协议.简单的说来,LD ...

  5. operamasks—omMessageBox的使用

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs&q ...

  6. SaltStack及Multi-Master介绍

    1.先说下SaltStack是啥? SaltStack是基于Python开发的一套C/S架构配置管理工具(功能不仅仅是配置管理,如使用salt-cloud配置AWS EC2实例),它的底层使用Zero ...

  7. day1--大数据概念,hadoop介绍,hdfs整体运行机制

    1.什么是大数据 基本概念 在互联网技术发展到现今阶段,大量日常.工作等事务产生的数据都已经信息化,人类产生的数据量相比以前有了爆炸式的增长,以前的传统的数据处理技术已经无法胜任,需求催生技术,一套用 ...

  8. js逻辑执行判断

    两个变量或者函数,如果与的关系,a && b,如果a是真则在运行b,如果a是假则不运行b了:如果是或的关系,前者是真则不运行后边的了,否则反过来. 举个例子: <span cla ...

  9. 省市联动选择的一个demo,利用vue+webpack+amaze-vue实现省市区联动选择组件

    https://github.com/sunshineJi/vue-city-picker

  10. ZOJ - 3471 Most Powerful (状态压缩)

    题目大意:有n种原子,两种原子相碰撞的话就会产生能量,当中的一种原子会消失. 问这n种原子能产生的能量最大是多少 解题思路:用0表示该原子还没消失.1表示该原子已经消失.那么就能够得到状态转移方程了 ...