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

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

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. loj2002 「SDOI2017」序列计数

    水题 #include <iostream> #include <cstring> #include <cstdio> using namespace std; t ...

  2. app启动画面(prepo)

    IPhone启动画面以及图标的设置 目前IPhone的分辨率为:320X480.640X960.640X1136. Default.png                    320X480 iPh ...

  3. Appium启动app

    首先要获取包名,然后获取launcherActivity.获取这两个关键东西的方法很多,这里就不一一多说,小伙伴们可以各显神通.小编这里主要给大家推荐一个sdk自带的实用工具aapt. aapt即An ...

  4. git删除本地所有的更改

    删除本地所有为暂存的修改: git checkout -f 如果有修改以及加入暂存区的话 那么 使用如下命令: git reset --hard git clean -xdf

  5. HDU 3271 SNIBB

    SNIBB Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 3271 ...

  6. 洛谷P4094 - [TJOI2016]字符串

    Portal Description 给出一个字符串\(s(|s|\leq10^5)\)和\(m\)次询问,每次询问子串\(s[x_1..x_2]\)的所有子串和\(s[y_1..y_2]\)的最长公 ...

  7. annotation之@Autowired、@Inject、@Resource三者区别

    一.@Autowired 1.@Autowired是spring自带的注解,通过‘AutowiredAnnotationBeanPostProcessor’ 类实现的依赖注入: 2.@Autowire ...

  8. [HNOI2002]彩票 (搜索+剪枝)

    题目描述 某地发行一套彩票.彩票上写有1到M这M个自然数.彩民可以在这M个数中任意选取N个不同的数打圈.每个彩民只能买一张彩票,不同的彩民的彩票上的选择不同. 每次抽奖将抽出两个自然数X和Y.如果某人 ...

  9. hdu 3711

    #include<stdio.h> #include<math.h> #include<stdlib.h> int cmp(const void *a,const ...

  10. 数字梯形(cogs 738)

    «问题描述:给定一个由n 行数字组成的数字梯形如下图所示.梯形的第一行有m 个数字.从梯形的顶部的m 个数字开始,在每个数字处可以沿左下或右下方向移动,形成一条从梯形的顶至底的路径.规则1:从梯形的顶 ...