CodeForces 608 A. Saitama Destroys Hotel(水~)
2016-02-29 21:37
453 查看
Description
一个s层的大楼有一个只能下的电梯,电梯初始在第s层,现在有n个人在ti时刻到达第fi层电梯处乘电梯到第0层,问电梯将这些人送到0层需要花费多少时间
Input
第一行两个整数n和s分别表示人数和大楼层数,之后n行每行两个整数fi和ti表示第i个人在ti时到达第fi层电梯处乘电梯
(1<=n<=100,1<=s<=1000,1<=fi<=s,1<=ti<=1000)
Output
输出将这n个人送到第0层最少花费多少时间
Sample Input
3 7
2 1
3 8
5 2
Sample Output
11
Solution
水题
Code
一个s层的大楼有一个只能下的电梯,电梯初始在第s层,现在有n个人在ti时刻到达第fi层电梯处乘电梯到第0层,问电梯将这些人送到0层需要花费多少时间
Input
第一行两个整数n和s分别表示人数和大楼层数,之后n行每行两个整数fi和ti表示第i个人在ti时到达第fi层电梯处乘电梯
(1<=n<=100,1<=s<=1000,1<=fi<=s,1<=ti<=1000)
Output
输出将这n个人送到第0层最少花费多少时间
Sample Input
3 7
2 1
3 8
5 2
Sample Output
11
Solution
水题
Code
#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> using namespace std; #define maxn 1111 int n,s,a[maxn],f,t; int main() { while(~scanf("%d%d",&n,&s)) { memset(a,0,sizeof(a)); for(int i=0;i<n;i++) { scanf("%d%d",&f,&t); a[f]=max(a[f],t); } int ans=0,time=0; for(int i=s;i>0;i--) { if(a[i]>=time)ans+=a[i]-time; time=++ans; } printf("%d\n",ans); } return 0; }
相关文章推荐
- 172. Factorial Trailing Zeroes
- 线程本地存储(Windows和Linux) http://blog.csdn.net/wzhwho/article/details/6427596
- Container With Most Water
- wait3和wait4 Functions
- SSH连接时出现Host key verification failed的原因及解决方法
- Low-rank representation with local constraint for graph construction
- git push origin master出错:error: failed to push some refs to
- STL容器与拷贝构造函数 http://blog.csdn.net/heyutao007/article/details/6702626
- Train Problem II(卡特兰数+大数乘除)
- C++ vector 类学习笔记 http://blog.csdn.net/whz_zb/article/details/6827999
- ZOJ Paint the Grid Reloaded
- 【杭电oj】1702 - ACboy needs your help again!(栈和队列)
- HDU 1022 Train Problem I(stack)
- View、Canvas、Paint
- 详解Paint的setShader(Shader shader)
- aix5.3下安装svn命令
- PRVF-4661 During cluvfy on AIX platform
- 【分布式存储】GlusterFS failing to mount at boot with Ubuntu 14.04
- win10 Failed to open/create the internal network 'HostInterfaceNetworking-VirtualBox Host
- 11.2 Job Seperation causes WARNINGS and ORA-15025 ORA-27041 With Certain Users (文档 ID 1317692.1)