Codeforces Round #336 (Div. 2) A
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 sand 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.
题意:s层楼 电梯1秒下一层 并且只能向下 n个人 在不同楼层 以及到达该楼层的时间
题解;到达的0层的时间
水
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
using namespace std;
int n,s;
int a[];
int maxn;
int l,r;
int main()
{
scanf("%d %d",&n,&s);
for(int i=;i<=s;i++)
{
a[i]=;
}
for(int i=;i<=n;i++)
{
scanf("%d %d",&l,&r);
if(r>a[l])
a[l]=r;
}
int maxn=-;
for(int i=s;i>=;i--)
{
{
if(a[i]>maxn)
maxn=a[i];
else
maxn++;
}
}
cout<<maxn<<endl;
return ;
}
Codeforces Round #336 (Div. 2) A的更多相关文章
- Codeforces Round #336 (Div. 2) D. Zuma
Codeforces Round #336 (Div. 2) D. Zuma 题意:输入一个字符串:每次消去一个回文串,问最少消去的次数为多少? 思路:一般对于可以从中间操作的,一般看成是从头开始(因 ...
- Codeforces Round #336 (Div. 2) D. Zuma 记忆化搜索
D. Zuma 题目连接: http://www.codeforces.com/contest/608/problem/D Description Genos recently installed t ...
- Codeforces Round #336 (Div. 2) C. Chain Reaction set维护dp
C. Chain Reaction 题目连接: http://www.codeforces.com/contest/608/problem/C Description There are n beac ...
- Codeforces Round #336 (Div. 2)B. Hamming Distance Sum 前缀和
B. Hamming Distance Sum 题目连接: http://www.codeforces.com/contest/608/problem/A Description Genos need ...
- Codeforces Round #336 (Div. 2)A. Saitama Destroys Hotel 水题
A. Saitama Destroys Hotel 题目连接: http://www.codeforces.com/contest/608/problem/A Description Saitama ...
- 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) D. Zuma(区间DP)
题目链接:https://codeforces.com/contest/608/problem/D 题意:给出n个宝石的颜色ci,现在有一个操作,就是子串的颜色是回文串的区间可以通过一次操作消去,问最 ...
- Codeforces Round #336 (Div. 2)
水 A - Saitama Destroys Hotel 简单的模拟,小贪心.其实只要求max (ans, t + f); #include <bits/stdc++.h> using n ...
- Codeforces Round #336 (Div. 2) D. Zuma 区间dp
D. Zuma Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gems ...
- Codeforces Round #336 (Div. 2)C. Chain Reaction DP
C. Chain Reaction There are n beacons located at distinct positions on a number line. The i-th bea ...
随机推荐
- python json.dumps raise TypeError(repr(o) + " is not JSON serializable") TypeError: 0 is not JSON serializable
出错如题. 这个问题有可能是因为python的json.dumps没法识别dump内容里的某些数据类型导致的.我的问题是因为dict中含有numpy.int64,numpy.float等类型导致的,需 ...
- 原生js关闭窗口
if (navigator.userAgent.indexOf("MSIE") > 0) { if (navigator.userAgent.indexOf("MS ...
- 【c学习-5】
int main(){ //二维数组的应用 int i,j; int a[2][3]; for(i=0;i void myFunction(){ int a[3]; int i; int max; f ...
- React路由-基础篇
React-Router-DOM ReactRouter网址, 安装 -npmjs找到react-router-dom -yarn add react-router-dom 基本使用方法 1.创建一个 ...
- ethereum(以太坊)(十三)--异常处理/元祖
pragma solidity ^0.4.4; contract Students{ uint[] data= new uint[](4); address _owner = msg.sender; ...
- 【笔记】objdump命令的使用
---恢复内容开始--- objdump命令是Linux下的反汇编目标文件或者可执行文件的命令,它还有其他作用,下面以ELF格式可执行文件test为例详细介绍: objdump -f test 显示t ...
- QWidget 自带的最大化,最小化,关闭按键的设置
使用函数 setWindowFlags 参数: CustomizeWindowHint 去掉窗口所有自带按钮 Qt::CustomizeWindowHint | Qt::WindowCloseButt ...
- poj 1957 二分搜索
题意:N个灯泡离地H_i,满足H1 = A ,Hi = (Hi-1 + Hi+1)/2 – 1,HN = B ,求最小B. 思路: 只要二分第二个灯泡的高度就可以推出全部灯泡的高度 如果hi<0 ...
- struts2官方 中文教程 系列五:处理表单
先贴个本帖的地址,免得其它网站被爬去了struts2教程 官方系列五:处理表单 即 http://www.cnblogs.com/linghaoxinpian/p/6906298.html 下载本章 ...
- Python 3基础教程4-变量
本文介绍变量,什么是变量呢,可以这样理解:变量是一个容器,这个容器可以用来存储值,而且可以被其他对象引用. 看看下面的demo.py # 这里介绍 变量 # 变量可以是数字var1 = 5print( ...