题目链接:http://poj.org/problem?id=1661
标准的DP,首先将输入数据按高度进行排序,将开始下落的位置初始化为左右坐标均为x,高度为y的平台(方便统一处理),然后从上至下搜寻最短路径。。
DP的思想已经掌握了,但是各种细节的处理还是远远达不到,这里贴出大神的代码,以示参考
#include<stdio.h>
#include<string.h>
#include<memory.h>
#include<stdlib.h>
#define INF 1000000
struct platform{
int lx,rx,h;
}p[1010];
int leftmin[1010],rightmin[1010];
int n,MAX;
int compare(const void * e1,const void * e2)
{
struct platform * p1,* p2;
p1 = (struct platform *)e1;
p2 = (struct platform *)e2;
return p2->h - p1->h;
}
int mintime(int L,int flag)
{
int y = p[L].h;
int x,i,ltime,rtime;
if(flag)
x = p[L].lx;
else