博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #336 (Div. 2)A. Saitama Destroys Hotel 水题
阅读量:6283 次
发布时间:2019-06-22

本文共 1630 字,大约阅读时间需要 5 分钟。

A. Saitama Destroys Hotel

题目连接:

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
using namespace std;#define maxn 1005int 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<
<

转载地址:http://rcxva.baihongyu.com/

你可能感兴趣的文章
rpmfusion 的国内大学 NEU 源配置
查看>>
spring jpa 配置详解
查看>>
IOE,为什么去IOE?
查看>>
java 用反射简单应用,将Object简单转换成map
查看>>
Storm中的Worker
查看>>
dangdang.ddframe.job中页面修改表达式后进行检查
查看>>
Web基础架构:负载均衡和LVS
查看>>
Linux下c/c++相对路径动态库的生成与使用
查看>>
SHELL实现跳板机,只允许用户执行少量允许的命令
查看>>
SpringBoot 整合Redis
查看>>
2014上半年大片早知道
查看>>
Android 6.0指纹识别App开发案例
查看>>
正文提取算法
查看>>
轻松学PHP
查看>>
Linux中的网络监控命令
查看>>
this的用法
查看>>
windows下安装redis
查看>>
CentOS7 yum 安装git
查看>>
启动日志中频繁出现以下信息
查看>>
httpd – 对Apache的DFOREGROUND感到困惑
查看>>