CodeForces 608A Saitama Destroys Hotel
来源:互联网 发布:编程有几种语言 编辑:程序博客网 时间:2024/06/05 05:59
FAQ | About Virtual Judge | Forum | Discuss | Open Source Project
题意: 一共有n个人 , s层高的大楼,电梯起初在顶层S;每个人所在楼层和到达电梯口的时间可能不同,求把所有人 带到底楼(就是1层),所用的最小时间~
思路::: 一开始 我认为谁先到楼梯口 就去接谁,可后来发现这是错的~
应该直接是 从顶楼开始往一楼接人 电梯只降不升,如果在该层的人还没来 就等到他来,原因是因为:就算你先下去接先到的人,但是你还是要返回来接高楼层的人,如果返回用的时间太大 大于高楼层人到达楼梯口时间 就错了~~~
代码:
#include<iostream>#include<cstdio>#include<cmath>#include<queue>#include<algorithm>#include<cstring>#include<cstdlib>#define max(a,b)(a>b?a:b)#define min(a,b)(a<b?a:b)#define INF 999999999using namespace std;typedef long long ll;struct node{ int f; int t;};bool cmp(node a,node b){ return a.f>b.f;}int main(){ int n,s,i; struct node p[110]; while(scanf("%d%d",&n,&s)!=EOF) { for(i=1;i<=n;i++) scanf("%d%d",&p[i].f,&p[i].t); sort(p+1,p+n+1,cmp); int ans=0; p[0].f=s; for(i=1;i<=n;i++) { ans=ans+abs(p[i-1].f-p[i].f); if(ans<p[i].t) ans=p[i].t; } printf("%d\n",ans+p[n].f); } return 0;}
0 0
- CodeForces 608A Saitama Destroys Hotel
- Saitama Destroys Hotel CodeForces - 608A
- CodeForces 608 A. Saitama Destroys Hotel(水~)
- CodeForces 608A Saitama Destroys Hotel(水题)
- A. Saitama Destroys Hotel
- Codeforces Round #336 (Div. 2)A. Saitama Destroys Hotel
- Saitama Destroys Hotel
- 贪心 Saitama Destroys Hotel
- Saitama Destroys Hotel
- 【Codeforces Round 336 (Div 2) A】【贪心 水题】Saitama Destroys Hotel 电梯只下不上 接n人到达0层最早时刻
- Codeforces 491B New York Hotel 题解
- Hotel
- Hotel
- Hotel
- Hotel
- Hotel
- Hotel
- codeforces 491B New York Hotel(贪心,数学)
- BZOJ2809——[Apio2012]dispatching
- [Ruby] 网页添加文本编辑器 Kindeditor for Ruby on Rails
- 5年,职业身涯的变迁思考
- 面向微信的WebApp产品观
- 安卓布局知识点
- CodeForces 608A Saitama Destroys Hotel
- 监听器的3种类型
- python 使用mysqldb模块通过ssh隧道连接mysql
- pulltorefresh(二)的自定义属性介绍、attrs文件介绍
- 《Practical Python and OpenCV+ Case Studies》电子书分享
- Decision Tree
- Canvas——标准五星红旗画法
- 简单XML文件
- [Sencha ExtJS & Touch] 表格(Ext.grid.Grid) 和 表格视图选项(Ext.grid.plugin.ViewOptions) 使用的时候要注意的问题