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

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

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. 工作中的Python脚本

    本章内容 1.rawlog处理   2.域名item接口刷新 3.备案结果查询 4.多级域名中取主域 5.发送邮件 6.通过api获取cdn edge ip 7.多线程下载 1.rawlog处理 脚本 ...

  2. document文档碎片

    var arrText = ["1","2","3","4","5","6",& ...

  3. luogu1131 [ZJOI2007]时态同步

    num[x]表示x到达叶子最远路径. 每个子节点对答案的贡献是num[x] - (num[t] + edge[i].val) #include <iostream> #include &l ...

  4. Java包(package)详解

    java包的作用是为了区别类名的命名空间 1.把功能相似或相关的类或接口组织在同一个包中,方便类的查找和使用.. 2.如同文件夹一样,包也采用了树形目录的存储方式.同一个包中的类名字是不同的,不同的包 ...

  5. numpy.clip(a, a_min, a_max, out=None)(values < a_min are replaced with a_min, and those > a_max with a_max.)

    numpy.clip(a, a_min, a_max, out=None) Clip (limit) the values in an array. Given an interval, values ...

  6. 刷题总结:最长公共字串(spoj1811)(后缀自动机)

    题目: 就不贴了吧···如题: 题解: 后缀自动机模版题:没啥好说的···· 代码: #include<iostream> #include<cstdio> #include& ...

  7. 刷题总结——road(ssoi)

    题目: 题目背景 SOURCE:NOIP2016-RZZ-1 题目描述 有 N 个城市,这些城市通过 M 条无向边互相连通,每条边有一个权值 Ci ,表示这条边的长度为 2^(Ci) ,没有两条边的长 ...

  8. 程序自动分析(codevs 4600)

    题目描述 Description 在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足. 考虑一个约束满足问题的简化版本:假设x1,x2,x3,…代表程序中出现的变量,给定n个形如xi ...

  9. 蜥蜴 BZOJ 1066

    蜥蜴 [问题描述] 在一个r行c列的网格地图中有一些高度不同的石柱,一些石柱上站着一些蜥蜴,你的任务是让尽量多的蜥蜴逃到边界外. 每行每列中相邻石柱的距离为1,蜥蜴的跳跃距离是d,即蜥蜴可以跳到平面距 ...

  10. apxs添加apache模块

    根phpize很类似,可以用apxs为Apache打模块: 要使用apxs,你的平台必须支持DSO特性, 而且Apache的httpd必须内建了mod_so模块.查看一下 httpd -l | gre ...