第四届河南省acm省赛 BOBSLEDDING
来源:互联网 发布:csgofps优化cfg 编辑:程序博客网 时间:2024/05/17 10:04
BOBSLEDDING
- 描述
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.
- 输入
- There are multi test cases,your program should be terminated by EOF
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 - 输出
- Line 1: A single integer, representing the maximum speed which Dr.Kong can attain between the start and the finish line, inclusive.
- 样例输入
14 3 7 311 113 8
- 样例输出
5
- 来源
第四届河南省程序设计大赛
题意:
给你L长度的路,然后给你多少个转弯的地点,那个地点有个限制速度通过的,让你求从0到L之间的最大速度;
例
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 5 4 3 4 3 2 1 2 3 4#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int m,n;
int dp[1010];
int main()
{
while(~scanf("%d%d",&m,&n))
{
int i,a,b,j;
memset(dp,0,sizeof(dp));
for(i=0;i<n;i++)
{
scanf("%d%d",&a,&b);
dp[a]=b;
}
dp[0]=1;
int c;
for(i=1;i<=m;i++)
{
c=dp[i-1]+1;
if(dp[i]>=c||dp[i]==0)//dp[i]>=c是判断到这个点的速度是否大于这个点的限制速度,dp[i]==0是这个点没有限制速度。
dp[i]=c;//此时速度更新。
else
{
for(j=i;j>=0;j--)
{
if(dp[j]+1<dp[j-1])//反过来更新之前的速度,因为你如果一直加速会超过这个限制速度。
dp[j-1]=dp[j]+1;
}
}
}
int max1=-1;
/*for(i=0;i<=m;i++)
{
printf("%2d ",i);
}
printf("\n");*/
for(i=0;i<=m;i++)
{
if(max1<dp[i])
max1=dp[i];
//printf("%2d ",dp[i]);
}
printf("%d\n",max1);
}
return 0;
}
- 第四届河南省acm省赛 BOBSLEDDING
- 河南省第四届ACM程序设计大赛 问题 G: BOBSLEDDING
- 河南第四届ACM省赛(BOBSLEDDING)
- 河南省第四届acm省赛 Substring
- NYOJ305 表达式求值(河南省第四届ACM省赛)
- 第四届河南省ACM SUBSTRING 字符串处理
- 第四届河南省ACM 表达式求值 栈
- 第四届河南省ACM 节能 区间DP
- 第四届河南省acm省赛 走迷宫(二分法枚举差值和最大值最小值+DFS)
- 河南省第四届acm省赛 序号互换(进制转化)
- 河南省第四届acm省赛 表达式求值(栈的应用)
- 河南省第四届acm省赛 C:表达式求值 逆波兰表达式
- 问题 A: 序号互换 河南省第四届ACM程序设计大赛
- 河南省第四届ACM程序设计大赛 问题 F: SUBSTRING
- 第四届河南省ACM 序号互换 进制转换
- 第三届河南省acm省赛 房间安排
- 第三届河南省acm省赛 素数判定
- 第三届河南省acm省赛 BUYING FEED
- 前端上传组件Plupload
- dubbo框架总结
- 管理配置文件
- 文件管理器源码分析(五)
- bzoj 1050: [HAOI2006]旅行comf(最小生成树+并查集)
- 第四届河南省acm省赛 BOBSLEDDING
- 二维码问题
- unity5.x从入门到精通-7章
- dubbo简单入门例子
- 【算法】最近公共祖先(hihoCoder #1062)
- iOS判断耳机是否插入
- 『Python标准库』学习笔记
- iOS 8 之后的动态沙盒路径
- UITextField 限制值输入数字和英文