CodeForces 608 A. Saitama Destroys Hotel(水~)
来源:互联网 发布:淘宝上有卖少女脚皮的 编辑:程序博客网 时间:2024/06/05 03:34
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
#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>using namespace std;#define maxn 1111int 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;}
0 0
- CodeForces 608 A. Saitama Destroys Hotel(水~)
- CodeForces 608A Saitama Destroys Hotel
- Saitama Destroys Hotel CodeForces - 608A
- CodeForces 608A Saitama Destroys Hotel(水题)
- A. Saitama Destroys Hotel
- Codeforces Round #336 (Div. 2)A. Saitama Destroys Hotel
- Saitama Destroys Hotel
- 贪心 Saitama Destroys Hotel
- Saitama Destroys Hotel
- 【Codeforces Round 336 (Div 2) A】【贪心 水题】Saitama Destroys Hotel 电梯只下不上 接n人到达0层最早时刻
- codeforces 491B New York Hotel(贪心,数学)
- Codeforces 491B New York Hotel 题解
- Hotel
- Hotel
- Hotel
- Hotel
- Hotel
- Hotel
- The requested URL could not be retrieved
- GCC弱符号的一个应用示例
- Cpp_操作符重载
- 构建自己的代码库及软件开发不能是加工作坊--及一个简单的Linux C程序开发框架—linux-dev-framework
- 定位的一个yaffs2文件系统的bug
- CodeForces 608 A. Saitama Destroys Hotel(水~)
- 数据库备份了解
- Messenger(信使)
- 2015年第六届蓝桥杯C/C++程序设计本科B组省赛 牌型种数(结果填空)
- hdoj--5619--Jam's store(最小费用最大流)
- Redis与MySql结合
- 数据结构 栈 链表
- 百度2014笔试算法题
- HOJ 2985 Wavio Sequence(最长递增子序列以及其O(n*logn)算法)