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

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

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
HDOJ Monthly Contest – 2010.06.05
Recommend
lcy   |   We have carefully selected several similar problems for you:  3422 3421 3423 3418 3419
 1 #include<math.h>
 2 #include<stdio.h>
 3 #include<string.h>
 4 #include<iostream>
 5 #include<algorithm>
 6 using namespace std;
 7 #define N 1234567
 8
 9 int n;
10 int a[N];
11 int b[N];
12
13 int main()
14 {
15     while(~scanf("%d",&n))
16     {
17         int ma=0;
18         for(int i=0;i<n;i++)
19         {
20             scanf("%d",&a[i]);
21         }
22         sort(a,a+n);
23         for(int i=0;i<n;i++)
24         {
25             b[i]=a[i]*(n-i);
26             ma=max(ma,b[i]);
27         }
28         cout<<ma<<endl;
29     }
30     return 0;
31 }

转载于:https://www.cnblogs.com/wmxl/p/4690786.html

HDU 3420 Bus Fair [补]相关推荐

  1. HDU 5552 Bus Routes(2015合肥现场赛A,计数,分治NTT)

    题意  给定n个点,任意两点之间可以不连边也可以连边.如果连边的话可以染上m种颜色. 求最后形成的图,是一个带环连通图的方案数. 首先答案是n个点的图减去n个点能形成的树. n个点能形成的树的方案数比 ...

  2. HDU 1690 Bus System

    HDU_1690 直接用Floyd算法求出任意两点之间的最少花费即可. #include<stdio.h>#include<string.h>#include<stdli ...

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

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

  4. 杭电OJ分类题目(4)-Graph

    原题出处:HDOJ Problem Index by Type,http://acm.hdu.edu.cn/typeclass.php 杭电OJ分类题目(4) HDU Graph Theory - U ...

  5. ACM—最短路—8月14日

    ACM-最短路-8月14日 训练网址: http://acm.hdu.edu.cn/diy/contest_show.php?cid=24386 学习博客 最小生成树与最短路径的区别以及实现方法 - ...

  6. 2019暑期多校补题情况 hdu

    hdu: Ο 以补 .   未补 题号 A B C D E F G H I J K L 状态 . Ο . Ο Ο . . . . . . . 第一场: 现场: 1004:思路 1005:板子最短路+最 ...

  7. 2018 HDU多校第四场赛后补题

    2018 HDU多校第四场赛后补题 自己学校出的毒瘤场..吃枣药丸 hdu中的题号是6332 - 6343. K. Expression in Memories 题意: 判断一个简化版的算术表达式是否 ...

  8. Bus System HDU - 1690 Foyd

    一.内容 Because of the huge population of China, public transportation is very important. Bus is an imp ...

  9. HDU 6446 Tree and Permutation(赛后补题)

    >>传送门<< 分析:这个题是结束之后和老师他们讨论出来的,很神奇:刚写的时候一直没有注意到这个是一个树这个条件:和老师讨论出来的思路是,任意两个结点出现的次数是(n-1)!, ...

最新文章

  1. I'm stuck! ccf模拟题。
  2. javascript实现小九九乘法口诀
  3. VTK:ShareCamera分享相机用法实战
  4. mybatis-逻辑翻页
  5. 还有多少人不会用K8s?.NET高级高薪岗,开始要求了!
  6. 面试篇------性能测试+调优
  7. es6生成器_ES6生成器
  8. django settings 定义的变量不存在_Django基础框架搭建
  9. 想学java编程从哪入手_初学编程从哪方面入手?
  10. java求第几位数字_怎么得到一个数的第n位数字 急求大神帮助
  11. 【2018 SWERC - C 】Crosswords【字典树、暴力搜索】
  12. 电路分析实验一 Pspice编写电路程序并运行
  13. 在Windows上将桌面图标做成贪吃蛇游戏
  14. Visual studio解决方案管理器找不到了怎么办
  15. 3、Azure Devops之Azure Repos篇
  16. 【Linux】uptime命令详解平均负载
  17. Docker创建容器找不到网卡:Error response from daemon: network xxxx not found
  18. JAVA TIME API总结
  19. 与域名空间推销员的QQ对话
  20. 2019.2.22 前端的精髓 动态js生成页面

热门文章

  1. python elem_Python
  2. 安装Docker Desktop报错WSL 2 installation is incomplete
  3. IntelliJ IDEA中使用sonar插件,忽略规则和重启规则
  4. 【CSP201803-1 】跳一跳,简单模拟
  5. 开发商微信选房后不退认筹金_新楼盘开盘的“认筹”和“认购”,劝您看懂后再去认!...
  6. npm设置仓库register
  7. python request请求参数_使用python将请求的requests headers参数格式化方法
  8. SQL面试题--(26~46)
  9. OpenGL基础41:几何着色器
  10. hduoj 6000 2016CCPC-final B. Wash(贪心)