Codeforces Round #336 (Div. 2)A. Saitama Destroys Hotel 水题
A. Saitama Destroys Hotel
题目连接:
http://www.codeforces.com/contest/608/problem/A
Description
Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to s and elevator initially starts on floor s at time 0.
The elevator takes exactly 1 second to move down exactly 1 floor and negligible time to pick up passengers. Genos is given a list detailing when and on which floor passengers arrive. Please determine how long in seconds it will take Genos to bring all passengers to floor 0.
Input
The first line of input contains two integers n and s (1 ≤ n ≤ 100, 1 ≤ s ≤ 1000) — the number of passengers and the number of the top floor respectively.
The next n lines each contain two space-separated integers fi and ti (1 ≤ fi ≤ s, 1 ≤ ti ≤ 1000) — the floor and the time of arrival in seconds for the passenger number i.
Output
Print a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.
Sample Input
3 7
2 1
3 8
5 2
Sample Output
11
Hint
题意
有一个电梯,一开始停靠在第s层,这个电梯很奇怪,只能往下走
有n个人,他们会在第t秒出现在第f层
电梯每下一层需要1s,问你把这些人全部送到0层,最少需要多少秒
题解:
暴力扫一遍就好了,暴力扫每一层,这个电梯最少多少秒到达这一层就好了
每一层到达的时间,由上一层决定
有点像dp
代码
#include<bits/stdc++.h>
using namespace std;
#define maxn 1005
int a[maxn];
int main()
{
int n,s;scanf("%d%d",&n,&s);
for(int i=1;i<=n;i++)
{
int x,t;scanf("%d%d",&x,&t);
a[x]=max(t,a[x]);
}
int x,y;
int ans=0;
for(int i=s;i>=0;i--)
{
ans = max(ans,a[i]);
ans++;
}
cout<<ans-1<<endl;
}
Codeforces Round #336 (Div. 2)A. Saitama Destroys Hotel 水题的更多相关文章
- Codeforces Round #336 (Div. 2) A. Saitama Destroys Hotel 模拟
A. Saitama Destroys Hotel Saitama accidentally destroyed a hotel again. To repay the hotel company ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos 水题
A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...
- Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题
A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...
- Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题
A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...
- Codeforces Round #384 (Div. 2) A. Vladik and flights 水题
A. Vladik and flights 题目链接 http://codeforces.com/contest/743/problem/A 题面 Vladik is a competitive pr ...
随机推荐
- 请教下 Yii 和 Ajax来验证用户名是否存在
添加一个 Custom, Model页面: CustomForm中: public function rules() { // 使用ajax 校验数据 return array( array('nam ...
- 自定义View绘制字符串
import android.app.Activity; import android.os.Bundle; import android.view.Display; import android.v ...
- 苹果将通过新Apple TV打造电视游戏平台 欲发力家庭游戏(转)
据<纽约时报>报道,9月10日凌晨1时举行的苹果发布会上将会公布新版Apple TV设备,还会推出TV版App Store.新设备以游戏作为主要卖点,图形性能将大幅提升. 苹果2015年秋 ...
- 数往知来SQL SERVER 视图 触发器 <九>
SQL server学习_视图 1.视图 视图其实是一张虚拟表,他是一张表的部分数据或多张表的综合数据(视图就是把SQL语句封装起来) 可以看做是一个结果集,但是不是一个结果集 视图不具备存储数据的能 ...
- 如何杀掉当前正在执行的hadoop任务
[root@Slave01 ~]# hadoop job -listDEPRECATED: Use of this script to execute mapred command is deprec ...
- [转]天龙八部的BillingServer
从字面上看,Billing是计费的,应该处理玩家在线时间或者包月之类.但是天龙八部是免费游戏,不需要算时间来计费.从代码中看,BillingServer也比较简单,它有一个连接到Web服务器,并监听一 ...
- MapReduce运行时出现java.lang.NoClassDefFoundError
最近在编写MapReduce程序时遇到了一个错误,错误提示信息为: Error: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.H ...
- 【调试】路由器设置不了静态IP -- clwu
办公室的路由器是IP-COM,原来可以设置静态IP 的,但后来不知道为什么比较长一段时间内设置不了,原来设置的静态IP 也不见了.现象是这样 什么都没有. 今天的网络被网管重调整过了,需要重新设置静态 ...
- rabbitMQ 远程访问
AMQP server localhost:5672 closed the connection. Check login credentials: Socket closed root@ruiy-c ...
- linux下生成 SSH 公钥,用于GitHub
ssh-keygen -t rsa -C <email> 参见 https://help.github.com/articles/generating-ssh-keys/ Then add ...