设$f[i][j][k]$为到达$(i,j)$,用时为$\frac{k}{5lcm}$小时的最低耗油量,然后DP即可。

#include<cstdio>
const int N=12,M=210005;
const double inf=1e15;
int n,L,lcm,lim,i,j,k,p,x,y,a[N],b[N],xs,ys,xt,yt,t1,t2,ans1=-1,ans2;
double f[2][N][M],w[N];
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void swap(int&a,int&b){int c=a;a=b;b=c;}
inline void up(double&a,double b){if(a>b)a=b;}
int cal(int x){
x*=12;
return x/lcm+(x%lcm>0);
}
int main(){
scanf("%d%d",&n,&L);
for(i=1;i<=10;i++)w[i]=1.0*L/(80.0-0.75*i*i);
for(i=1;i<=n;i++)scanf("%d",&a[i]),a[i]/=5;
for(i=1;i<=n;i++)scanf("%d",&b[i]),b[i]/=5;
for(i=1;i<=n;i++){
if(x<a[i])x=a[i];
if(x<b[i])x=b[i];
}
for(i=lcm=1;i<=x;i++)lcm=lcm*i/gcd(lcm,i);
scanf("%d%d%d%d%d%d",&xs,&ys,&xt,&yt,&t1,&t2);
lim=t2*lcm/12;
if(xs>xt)swap(xs,xt),swap(ys,yt);
if(ys>yt){
for(i=1,j=n;i<j;i++,j--)swap(a[i],a[j]);
ys=n-ys+1,yt=n-yt+1;
}
for(j=ys;j<=yt;j++)for(k=0;k<=lim;k++)f[0][j][k]=inf;
f[0][ys][0]=0;
for(i=xs;i<=xt;i++,p^=1){
for(j=ys;j<=yt;j++)for(k=0;k<=lim;k++)f[p^1][j][k]=inf;
for(j=ys;j<=yt;j++)for(k=0;k<=lim;k++)if(f[p][j][k]<inf){
if(j<yt)for(x=b[i];x;x--){
y=k+lcm/x*L;
if(y<=lim)up(f[p][j+1][y],f[p][j][k]+w[x]);
}
if(i<xt)for(x=a[j];x;x--){
y=k+lcm/x*L;
if(y<=lim)up(f[p^1][j][y],f[p][j][k]+w[x]);
}
}
}
for(k=0;k<=lim;k++)if(k*12>=t1*lcm&&f[p^1][yt][k]<inf){
if(ans1<0)ans1=k;
if(!ans2||f[p^1][yt][k]+1e-9<f[p^1][yt][ans2])ans2=k;
}
if(ans1<0)return puts("No"),0;
printf("%d %.2f\n%d %.2f",cal(ans1),f[p^1][yt][ans1],cal(ans2),f[p^1][yt][ans2]);
return 0;
}

  

BZOJ1075 : [SCOI2007]最优驾车drive的更多相关文章

  1. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  2. 【原】Learning Spark (Python版) 学习笔记(三)----工作原理、调优与Spark SQL

    周末的任务是更新Learning Spark系列第三篇,以为自己写不完了,但为了改正拖延症,还是得完成给自己定的任务啊 = =.这三章主要讲Spark的运行过程(本地+集群),性能调优以及Spark ...

  3. 【BZOJ】【1070】【SCOI2007】修车

    网络流/费用流 好神奇的建模= = 关键就是把每个技术员拆成n个点,表示这个技术员倒数第几个修的车子.. 考虑第i个工人,他修第j辆车只对后面要修的车有影响,而前面修过的车已经对当前没有影响了.而这个 ...

  4. 恒天云技术分享系列3 – KVM性能调优

    恒天云技术分享:http://www.hengtianyun.com/download-show-id-11.html KVM是什么 KVM 是 kernel-based Virtual Machin ...

  5. Sightseeing Cows(最优比率环)

    Sightseeing Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8915   Accepted: 3000 ...

  6. 性能优化之MySQL调优篇

    MySQL对于很多Linux从业者而言,是一个非常棘手的问题,多数情况都是因为对数据库出现问题的情况和处理思路不清晰.在进行MySQL的优化之前必须要了解的就是MySQL的查询过程,很多的查询优化工作 ...

  7. 最优比例生成环(dfs判正环或spfa判负环)

    http://poj.org/problem?id=3621 Sightseeing Cows Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  8. POJ 3621 Sightseeing Cows(最优比例环+SPFA检测)

    Sightseeing Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10306   Accepted: 3519 ...

  9. poj 3621(最优比率环)

    Sightseeing Cows Farmer John has decided to reward his cows for their hard work by taking them on a ...

随机推荐

  1. sizeof()和strlen()的区别与联系

    参考:http://www.cnblogs.com/carekee/articles/1630789.html 1.sizeof是运算符,其值在编译时即计算好了,参数可以是数组.指针.类型.对象.函数 ...

  2. HDOJ 1590

    #include<stdio.h> #include<iostream> #include<stdlib.h> #include<string.h> u ...

  3. javascript memoization递归优化

    memoize优化递归 function createRec(callback, cache) { cache = cache || []; var rec = function(n) { (n in ...

  4. sc 与net命令的区别

    windows服务操作命令有sc和net 两个命令; sc stop serviceName  sc start serviceName net stop serviceName  net start ...

  5. 在64位的linux上运行32位的程序

    1.症状 (1)执行bin文件时提示:No such file or directory (2)ldd bin文件  的输出为: not a dynamic executable (3)file bi ...

  6. 用几条shell命令快速去重10G数据

    试想一下,如果有10G数据,或者更多:怎么才能够快速地去重呢?你会说将数据导入到数据库(mysql等)进行去重,或者用java写个程序进行去重,或者用Hadoop进行处理.如果是大量的数据要写入数据库 ...

  7. cocos2d c++ 代码规范(译文)

    原文在http://cocos2d-x.org/projects/cocos2d-x/wiki/Cocos2d_c++_coding_style,我觉得这个规范非常全面,写的非常好,我只捡一些我认为比 ...

  8. iOS8 UILocalNotification 和 UIRemoteNotification 使用注意 草稿,正在整理中。。。。

    先说一个关于UILocalNotification的知识点,容易被忘记: Each app on a device is limited to 64 scheduled local notificat ...

  9. iOS constraint被应用于view上的时间

    在viewdidload时,constraint是没有被应用的,之后在layoutSubviews时,系统应用了constraint.但是我感觉在viewWillLayoutSubviews函数时就已 ...

  10. codeforces A. IQ Test 解题报告

    题目链接:http://codeforces.com/problemset/problem/328/A 一开始单纯地直接判断给出的序列是等差还是等比,连这一句“You should also prin ...