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 ...
随机推荐
- hibernate映射实体类查询时数据库空字段赋值给实体类报错的问题
因为一直报实体类空异常,去网上查了资料只查到了并没有查到数据库空值时不给实体类赋值的属性 异常 org.hibernate.InvalidMappingException: Could not par ...
- webstorm报错Unescaped xml character解决方案1
当idea认为你的书写格式不适合的时候便会报出Unescaped xml character提示,但不影响运行. 若想禁掉这个提示,可以尝试修改文档类型为:<!DOCTYPE html>
- java多线程批量读取文件(七)
新公司入职一个多月了,至今没有事情可以做,十来个新同事都一样抓狂,所以大家都自己学习一些新东西,我最近在看zookeeper,感觉蛮不错的,和微服务的zuul以及eureka功能类似,只是代码复杂了一 ...
- MAC下MySQL初始密码忘记修改初始密码
解决MAC下MySQL忘记初始密码的方法分享给大家,供大家参考,具体内容如下 第一步: 点击系统偏好设置->最下边点MySQL,在弹出页面中,点击stop MySQL Servier,输入密码关 ...
- JS实现禁用滑动条但滑动条不消失的效果
//方法 //滑动条 // left: 37, up: 38, right: 39, down: 40, // spacebar: 32, pageup: 33, pagedown: 34, end: ...
- Hive 的企业优化
优化 数据优化 一.从大表拆分成小表(更快地检索) 引用:Hive LanguageManual DDL eg2:常用于分表 create table if not exists default.ce ...
- idea录制宏
录制一个热部署的快捷键 1.打开Edit-->Macros-->statr Macro Recording 打开之后idea右下角就会出现一个小圆点 然后就可以开始录制自己想要的快捷键 按 ...
- 15.3,redis持久化RDB与AOF
redis持久化 Redis是一种内存型数据库,一旦服务器进程退出,数据库的数据就会丢失,为了解决这个问题,Redis提供了两种持久化的方案,将内存中的数据保存到磁盘中,避免数据的丢失. RDB持久化 ...
- 3336 /P1948电话网络(二分答案)
3336 电话网络 时间限制: 1 s 空间限制: 32000 KB 题目等级 : 黄金 Gold 题目描述 Description 由于地震使得连接汶川县城电话线全部损坏,假如你是 ...
- Java 泛型 二
一. 泛型概念的提出(为什么需要泛型)? 首先,我们看下下面这段简短的代码: 1 public class GenericTest { 2 3 public static void main(Stri ...