HDU 3420 Bus Fair [补]
今天玩魔灵玩多了,耽误了时间,回去宿舍又没电。
/*********************************************/
Bus Fair
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 900 Accepted Submission(s): 444
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.
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 [补]相关推荐
- HDU 5552 Bus Routes(2015合肥现场赛A,计数,分治NTT)
题意 给定n个点,任意两点之间可以不连边也可以连边.如果连边的话可以染上m种颜色. 求最后形成的图,是一个带环连通图的方案数. 首先答案是n个点的图减去n个点能形成的树. n个点能形成的树的方案数比 ...
- HDU 1690 Bus System
HDU_1690 直接用Floyd算法求出任意两点之间的最少花费即可. #include<stdio.h>#include<string.h>#include<stdli ...
- HDU 5552 Bus Routes(NTT+分治)
题意 给定 \(n\) 个点,任意连边,每条边有 \(m\) 种颜色可选,求带环连通图的方案数. \(1\leq n\leq 10000\) \(1\leq m < 2^{31}\) 思路 直接 ...
- 杭电OJ分类题目(4)-Graph
原题出处:HDOJ Problem Index by Type,http://acm.hdu.edu.cn/typeclass.php 杭电OJ分类题目(4) HDU Graph Theory - U ...
- ACM—最短路—8月14日
ACM-最短路-8月14日 训练网址: http://acm.hdu.edu.cn/diy/contest_show.php?cid=24386 学习博客 最小生成树与最短路径的区别以及实现方法 - ...
- 2019暑期多校补题情况 hdu
hdu: Ο 以补 . 未补 题号 A B C D E F G H I J K L 状态 . Ο . Ο Ο . . . . . . . 第一场: 现场: 1004:思路 1005:板子最短路+最 ...
- 2018 HDU多校第四场赛后补题
2018 HDU多校第四场赛后补题 自己学校出的毒瘤场..吃枣药丸 hdu中的题号是6332 - 6343. K. Expression in Memories 题意: 判断一个简化版的算术表达式是否 ...
- Bus System HDU - 1690 Foyd
一.内容 Because of the huge population of China, public transportation is very important. Bus is an imp ...
- HDU 6446 Tree and Permutation(赛后补题)
>>传送门<< 分析:这个题是结束之后和老师他们讨论出来的,很神奇:刚写的时候一直没有注意到这个是一个树这个条件:和老师讨论出来的思路是,任意两个结点出现的次数是(n-1)!, ...
最新文章
- I'm stuck! ccf模拟题。
- javascript实现小九九乘法口诀
- VTK:ShareCamera分享相机用法实战
- mybatis-逻辑翻页
- 还有多少人不会用K8s?.NET高级高薪岗,开始要求了!
- 面试篇------性能测试+调优
- es6生成器_ES6生成器
- django settings 定义的变量不存在_Django基础框架搭建
- 想学java编程从哪入手_初学编程从哪方面入手?
- java求第几位数字_怎么得到一个数的第n位数字 急求大神帮助
- 【2018 SWERC - C 】Crosswords【字典树、暴力搜索】
- 电路分析实验一 Pspice编写电路程序并运行
- 在Windows上将桌面图标做成贪吃蛇游戏
- Visual studio解决方案管理器找不到了怎么办
- 3、Azure Devops之Azure Repos篇
- 【Linux】uptime命令详解平均负载
- Docker创建容器找不到网卡:Error response from daemon: network xxxx not found
- JAVA TIME API总结
- 与域名空间推销员的QQ对话
- 2019.2.22 前端的精髓 动态js生成页面
热门文章
- python elem_Python
- 安装Docker Desktop报错WSL 2 installation is incomplete
- IntelliJ IDEA中使用sonar插件,忽略规则和重启规则
- 【CSP201803-1	】跳一跳,简单模拟
- 开发商微信选房后不退认筹金_新楼盘开盘的“认筹”和“认购”,劝您看懂后再去认!...
- npm设置仓库register
- python request请求参数_使用python将请求的requests headers参数格式化方法
- SQL面试题--(26~46)
- OpenGL基础41:几何着色器
- hduoj 6000 2016CCPC-final B. Wash(贪心)