BOBSLEDDING
来源:互联网 发布:高分少女 知乎: 编辑:程序博客网 时间:2024/06/05 00:16
Dr.Kong has entered a bobsled competition because he hopes his hefty weight will give his an advantage over the L meter course (2 <= L<= 1000). Dr.Kong will push off the starting line at 1 meter per second, but his speed can change while he rides along the course. Near the middle of every meter Bessie travels, he can change his speed either by using gravity to accelerate by one meter per second or by braking to stay at the same speed or decrease his speed by one meter per second.
Naturally, Dr.Kong must negotiate N (1 <= N <= 500) turns on the way down the hill. Turn i is located T_i meters from the course start (1 <= T_i <= L-1), and he must be enter the corner meter at a peed of at most S_i meters per second (1 <= S_i <= 1000). Dr.Kong can cross the finish line at any speed he likes.
Help Dr.Kong learn the fastest speed he can attain without exceeding the speed limits on the turns.
Consider this course with the meter markers as integers and the turn speed limits in brackets (e.g., '[3]'):
0 1 2 3 4 5 6 7[3] 8 9 10 11[1] 12 13[8] 14
(Start) |------------------------------------------------------------------------| (Finish)
Below is a chart of Dr.Kong 's speeds at the beginning of each meter length of the course:
Max: [3] [1] [8]
Mtrs: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Spd: 1 2 3 4 5 5 4 3 4 3 2 1 2 3 4
His maximum speed was 5 near the beginning of meter 4.
Input
Line 1: Two space-separated integers: L and N
Lines 2..N+1: Line i+1 describes turn i with two space-separated integers: T_i and S_i
Output
Sample Input
14 3 7 311 113 8
Sample Output
5
AC代码:
#include<bits/stdc++.h>using namespace std;int main(){int L,N;int dp[1010];int t,s;int i,j,k;while(cin>>L>>N){memset(dp,0,sizeof(dp));for(i=0;i<N;i++){cin>>t>>s;dp[t]=s;}for(i=0;i<=L;i++){if(dp[i]==0)dp[i]=dp[i-1]+1;else {if(dp[i]>dp[i-1])dp[i]=dp[i-1]+1;else {k=i;while(dp[k-1]-dp[k]>1){dp[k-1]=dp[k]+1; k--;}}}}k=dp[0];for(i=1;i<=L;i++)k=max(k,dp[i]);cout<<k<<endl;}return 0;}
- BOBSLEDDING
- BOBSLEDDING (nyoj309)
- 309 BOBSLEDDING
- NYOJ BOBSLEDDING
- nysit 309 BOBSLEDDING
- nyoj 153 BOBSLEDDING
- USACO 2009 Dec Bobsledding
- NYOJ:309 BOBSLEDDING
- nyoj309 BOBSLEDDING(动态规划)
- nyoj 309 BOBSLEDDING 【贪心】
- NYOJ 309 BOBSLEDDING(dp)
- USACO 2009 Dec Bobsledding 滑雪比赛
- 河南第四届ACM省赛(BOBSLEDDING)
- 第四届河南省acm省赛 BOBSLEDDING
- NYOJ 309 BOBSLEDDING(细节题)
- bzoj3411 [Usaco2009 Dec]Bobsledding 高山滑雪
- BOBSLEDDING(一道有趣的贪心题 nyoj309)
- 河南省第四届ACM程序设计大赛 问题 G: BOBSLEDDING
- 请求编码与响应编码
- MQ基础
- SVN出现!和!M问题
- Android 同步网络时间
- 多重背包
- BOBSLEDDING
- 高通平台进FFBM的三种模式
- 《Head First C#》学习 ---第一个实例中遇到的问题
- ayoutSubviews layoutIfNeeded setNeedsLayout 的区别
- libcocos2dx 已停止运行
- 网络流
- 如何学习 Javascript
- 疯狂连连看学习心得-基于Android Studio 2.0
- 深入理解异步加载--Handler和Looper源码解析(1)