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

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

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. eclipse中tab键设置

    1.点击 window->preference-,依次选择 General->Editors->Text Editors,选中右侧的 insert space for tabs;如下 ...

  2. 解决win7下pycharm移动文件出现Clear Read-Only status移动失败的问题

    问题描述: 将pycharm中的文件move到指定文件夹或者将其他文件拖动到pycharm指定文件夹下,会出现如下问题导致文件移动失败: 出现这个问题的原因及解决办法如下: 第一种,pycharm下建 ...

  3. [uiautomator篇] uiautoviewer 定位不到元素

    定位工具: Uiautomatorviewer 在我们的APP中,只有这一个页面,元素无法加载出来,其它的都没有什么问题.   提示的错误:Error while obtaining UI hiera ...

  4. [luoguP2219] [HAOI2007]修筑绿化带(单调队列)

    传送门 需要n*m的算法,考虑单调队列 可以预处理出来 a[i][j]表示以i,j为右下角的绿化带+花坛的和 b[i][j]表示以i,j为右下角的花坛的和 那么我们可以单调队列跑出来在A-C-1,B- ...

  5. [BZOJ1594] [Usaco2008 Jan]猜数游戏(二分 + 并查集)

    传送门 题中重要信息,每堆草的数量都不一样. 可以思考一下,什么情况下才会出现矛盾. 1.如果两个区间的最小值一样,但是这两个区间没有交集,那么就出现矛盾. 2.如果两个区间的最小值一样,并且这两个区 ...

  6. 【邻接表+匈牙利算法模板】Elementary Math

    http://acm.bnu.edu.cn/v3/external/gym/101485.pdf #include<bits/stdc++.h> using namespace std; ...

  7. cf287E Main Sequence

    As you know, Vova has recently become a new shaman in the city of Ultima Thule. So, he has received ...

  8. [Python] 'unicode' object is not callable

    在Python中,出现'unicode' object is not callable的错误一般是把字符串当做函数使用了.

  9. Linux c内存泄漏检测

    在Linux下些C语言程序,最大的问题就是没有一个好的编程IDE,当然想kdevelop等工具都相当的强大,但我还是习惯使用kdevelop工具,由于没有一个习惯的编程IDE,内存检测也就成了在Lin ...

  10. Poi写文件时报java.io.IOException: Read error

    使用POI报表时不停的报java.io.IOException: Read error,看网上是说关闭了InputStream所导致的,由于我的InputStream是读取和写入都是用的同一个,所以就 ...