Codefroces A. Saitama Destroys Hotel
1 second
256 megabytes
standard input
standard output
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.
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.
Print a single integer — the minimum amount of time in seconds needed to bring all the passengers to floor 0.
3 7
2 1
3 8
5 2
11
5 10
2 77
3 33
8 21
9 12
10 64
79
In the first sample, it takes at least 11 seconds to bring all passengers to floor 0. Here is how this could be done:
1. Move to floor 5: takes 2 seconds.
2. Pick up passenger 3.
3. Move to floor 3: takes 2 seconds.
4. Wait for passenger 2 to arrive: takes 4 seconds.
5. Pick up passenger 2.
6. Go to floor 2: takes 1 second.
7. Pick up passenger 1.
8. Go to floor 0: takes 2 seconds.
This gives a total of 2 + 2 + 4 + 1 + 2 = 11 seconds.
算出每个人到0层的时间,最大值和s比较
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
int n,s,a,b,max=;
cin>>n>>s;
for(int i=;i<n;i++)
{
cin>>a>>b;
if(a+b>max) max=a+b;
}
if(s>max) cout<<s<<endl;
else cout<<max<<endl;
return ;
}
Codefroces 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 #336 (Div. 2)A. Saitama Destroys Hotel 水题
A. Saitama Destroys Hotel 题目连接: http://www.codeforces.com/contest/608/problem/A Description Saitama ...
- Codeforces 608 A. Saitama Destroys Hotel
A. Saitama Destroys Hotel time limit per test 1 second memory limit per test 256 megabytes input ...
- CodeForces - 608A-Saitama Destroys Hotel(模拟)
Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to o ...
- Codeforces Round #336 (Div. 2)
水 A - Saitama Destroys Hotel 简单的模拟,小贪心.其实只要求max (ans, t + f); #include <bits/stdc++.h> using n ...
- Codeforces Round #336 (Div. 2)【A.思维,暴力,B.字符串,暴搜,前缀和,C.暴力,D,区间dp,E,字符串,数学】
A. Saitama Destroys Hotel time limit per test:1 second memory limit per test:256 megabytes input:sta ...
- Codeforces Round #336 (Div. 2)-608A.水题 608B.前缀和
A题和B题... A. Saitama Destroys Hotel time limit per test 1 second memory limit per test 256 megabyte ...
- Codeforces Round #336 (Div. 2) A
A. Saitama Destroys Hotel time limit per test 1 second memory limit per test 256 megabytes input sta ...
- POJ 3667 Hotel(线段树 区间合并)
Hotel 转载自:http://www.cnblogs.com/scau20110726/archive/2013/05/07/3065418.html [题目链接]Hotel [题目类型]线段树 ...
随机推荐
- 一 Storm 基础
1 Storm 分布式计算结构称为 Topology (拓扑) Topology 由 stream(数据流).spout(数据流的生成者).bolt(运算)组成. ...
- python __future__ 的几种特性
今天看tensorflow的代码,看到python里面有这么几句: from __future__ import absolute_import from __future__ import divi ...
- UE4 中的人工智能解析—ShooterGame为例
在UE4编辑器中,打开内容浏览器,右击鼠标,创建传说中的行为树: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQTM2MzA2MjM=/font/5a6L ...
- 将一个文件夹纳入library或者移除remove
https://support.microsoft.com/en-us/help/4026298/windows-show-libraries-in-file-explorer To show lib ...
- zzulioj--1804--ZY学长的密码(字符串)
1804: ZY学长的密码 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 140 Solved: 53 SubmitStatusWeb Board ...
- [AGC018 B] Sports Festival 解题报告
题目链接:https://agc018.contest.atcoder.jp/tasks/agc018_b 题目: 题目大意: 有N个人参加M个体育项目,每个人对体育项目的喜爱程度有一个排名,A[i] ...
- 点击鼠标右键弹出错误提示:CrashHandler initialization error
电脑重装系统后,什么都没有了,重装部分必须用的软件后,不管是在桌面还是在文件夹中,当点击鼠标右键时,总是弹出错误,如下图所示: 上网找解决方法,也没有找到,但是看错误,是与SVN有关. 产生原因:To ...
- 记intel杯比赛中各种bug与debug【其四】:基于长短时记忆神经网络的中文分词的实现
(标题长一点就能让外行人感觉到高大上) 直接切入主题好了,这个比赛还必须一个神经网络才可以 所以我们结合主题,打算写一个神经网络的中文分词 这里主要写一下数据的收集和处理,网络的设计,代码的编写和模型 ...
- ubuntu 安装Gremlin 的图形化环境
参考文档:https://www.jianshu.com/p/618cf6667381 部署HugeGraphServer # 直接下载release包 网址:https://github.com/h ...
- caioj 1072 动态规划入门(二维一边推5:最长公共子序列 LCSS加强版)
在51nod刷到过同样的题,直接秒杀 见https://blog.csdn.net/qq_34416123/article/details/81697683 #include<cstdio> ...