今天玩魔灵玩多了,耽误了时间,回去宿舍又没电。

/*********************************************/

Bus Fair

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 900    Accepted Submission(s): 444

Problem Description
You
are now in Foolish Land. Once moving in Foolish Land you found that
there is a strange Bus fair system. The fair of moving one kilometer by
bus in that country is one coin. If you want to go to X km and your
friend wants to go to Y km then you can buy a ticket of X+Y coins (you
are also allowed to buy two or more tickets for you two).
  
Now
as a programmer, you want to show your creativity in buying tickets!
Suppose, your friend wants to go 1 km and you want to go 2 km. Then it’s
enough for you to buy a 2coin ticket! Because both of you are valid
passengers before crossing the first km. and when your bus cross the
first km your friend gets down from the bus. So you have the ticket of
2km! And you can safely reach to your destination, 2km using that
ticket.
  
Now, you have a large group of friends and they want to
reach to different distance. You think that you are smart enough that
you can buy tickets that should manage all to reach their destination
spending the minimum amount of coins. Then tell us how much we should at
least pay to reach our destination.
 
Input
There
are multiple test cases. Each case start with a integer n, the total
number of people in that group. 0<=n<=1000. Then comes n integers,
each of them stands for a distance one of the men of the group wants to
go to. You can assume that the distance a man wants to go is always
less than 10000.
 
Output
Your
program should print a single integer for a single case, the minimum
amount of coins the group should spend to reach to the destination of
all the members of that group.
 
Sample Input
2
1
2
2
2
3
 
Sample Output
2
4
 
Author
Muhammed Hedayet
 
Source
 
Recommend
lcy   |   We have carefully selected several similar problems for you:  3422 3421 3423 3418 3419
 #include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 1234567 int n;
int a[N];
int b[N]; int main()
{
while(~scanf("%d",&n))
{
int ma=;
for(int i=;i<n;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
for(int i=;i<n;i++)
{
b[i]=a[i]*(n-i);
ma=max(ma,b[i]);
}
cout<<ma<<endl;
}
return ;
}

HDU 3420 Bus Fair [补]的更多相关文章

  1. HDU 3420 -- Bus Fair ACM

    Bus Fair Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total S ...

  2. hdu 5552 Bus Routes

    hdu 5552 Bus Routes 考虑有环的图不方便,可以考虑无环连通图的数量,然后用连通图的数量减去就好了. 无环连通图的个数就是树的个数,又 prufer 序我们知道是 $ n^{n-2} ...

  3. hdu 1690 Bus System(Dijkstra最短路)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1690 Bus System Time Limit: 2000/1000 MS (Java/Others ...

  4. hdu 1690 Bus System (有点恶心)

    Problem Description Because of the huge population of China, public transportation is very important ...

  5. hdu 1690 Bus System (最短路径)

    Bus System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  6. hdu 2377 Bus Pass

    Bus Pass Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  7. HDU 1690 Bus System

    题目大意:给出若干巴士不同价格的票的乘坐距离范围,现在有N个站点,有M次询问,查询任意两个站点的最小花费 解析:由于是多次查询不同站点的最小花费,所以用弗洛伊德求解 时间复杂度(O^3) 比较基础的弗 ...

  8. HDU 5552 Bus Routes(NTT+分治)

    题意 给定 \(n\) 个点,任意连边,每条边有 \(m\) 种颜色可选,求带环连通图的方案数. \(1\leq n\leq 10000\) \(1\leq m < 2^{31}\) 思路 直接 ...

  9. HDU 4696 Answers (脑补+数形结合)

    题意 给一个图,每个点的出度为1,每个点的权值为1或者2.给Q个询问,问是否能找到一条路径的权值和M. 思路 由于每个点的出度为1,所以必然存在环.又因为c[i]只能取1或者2,可以组成任意值,所以只 ...

随机推荐

  1. Android兼容性测试GTS-环境搭建、测试执行、结果分析

    GTS的全称是Google Mobile Services Test Suite,所谓的Google Mobile Services即谷歌移动服务,是谷歌开发并推动Android的动力,也是Andro ...

  2. Ubuntu 清理卸载残留文件

    dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P

  3. 大数据学习——Storm学习单词计数案例

    需求:计算单词在文档中出现的次数,每出现一次就累加一次 遇到的问题 这个问题是<scope>provided</scope>作用域问题 https://www.cnblogs. ...

  4. TOJ 2710: 过河 路径压缩

    2710: 过河  Time Limit(Common/Java):1000MS/10000MS     Memory Limit:65536KByteTotal Submit: 32         ...

  5. 九度oj题目1008:最短路径问题

    题目描述: 给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的. 输入:                 ...

  6. [BZOJ3339] Rmq Problem(线段树)

    传送门 这个题的方法好像很多啊 1.莫队暴力 2.线段树 + 离线处理 先预处理出sg[i]表示前i个数的sg值,next[i]表示i的下一位置在哪里,如果后面再没有i,那么next[i] = n + ...

  7. 常州模拟赛d2t3 小X的佛光

    平日里最喜欢做的事就是蒸发学水.[题目描述]小 X 所在的城市 X 城是一个含有 N 个节点的无向图,同时,由于 X 国是一个发展中国家,为了节约城市建设的经费,X 国首相在建造 X 城时只建造 N ...

  8. tomcat设置去项目路径

    1. 新建一个目录专门用于存放工程, 如: G:\apache-tomcat-6.0.20\project 2. 将工程存放到以上目录下:即:G:\apache-tomcat-6.0.20\proje ...

  9. EC++学习笔记(四) 设计与声明

    条款18:让接口容易被正确使用,不易被误用 必须考虑客户可能做出什么样的错误(防御式编程)std:shared_ptr会自动使用它的"每个指针专属的删除器",消除了"cr ...

  10. gdb 远程调试android进程

    原文:http://blog.csdn.net/xinfuqizao/article/details/7955346?utm_source=tuicool 什么是gdb 它是gnu组织开发的一个强大的 ...