思路:

一维dp。

实现:

 #include <cstdio>
#include <iostream>
using namespace std;
const int INF = 0x3f3f3f3f;
int w[], v[], sum[];
double dp[];
int main()
{
int b, l, n;
while (cin >> b >> l >> n, b || l || n)
{
for (int i = ; i <= n; i++) dp[i] = INF;
for (int i = ; i <= n; i++)
{
cin >> w[i] >> v[i];
sum[i] = sum[i - ] + w[i];
}
dp[] = (double)l / v[];
for (int i = ; i <= n; i++)
{
int minn = v[i];
for (int j = i; j >= ; j--)
{
if (sum[i] - sum[j - ] > b) continue;
minn = min(minn, v[j]);
dp[i] = min(dp[i], dp[j - ] + (double)l / minn);
}
}
printf("%.1f\n", dp[n] * );
}
return ;
}

poj1857 To Europe! To Europe!的更多相关文章

  1. Fedora 22中的日期和时间配置

    Introduction Modern operating systems distinguish between the following two types of clocks: A real- ...

  2. Windows Azure Storage (17) Azure Storage读取访问地域冗余(Read Access – Geo Redundant Storage, RA-GRS)

    <Windows Azure Platform 系列文章目录> 细心的用户会发现,微软在国外和国内的数据中心建设都是成对的,比如香港数据中心(Asia East)和新加坡的数据中心(Sou ...

  3. android时区

    <timezones>    <timezone id="Pacific/Majuro">马朱罗</timezone>    <timez ...

  4. shell 脚本样例

    1  解压文件,移动文件,删除特定目录 #!/bin/bash pa=$(cd ``; pwd) //获得当前目录的绝对路径 v_dir=${pa} mkdir ${v_dir} dirDist=${ ...

  5. 使用celery之深入celery配置(转)

    原文:http://www.dongwm.com/archives/shi-yong-celeryzhi-shen-ru-celerypei-zhi/ 前言 celery的官方文档其实相对还是写的很不 ...

  6. Chinese culture

      文房四宝 笔墨纸砚是中国古代文人书房中必备的宝贝,被称为“文房四宝”.用笔墨书写绘画在 中国可追溯到五千年前.秦(前221---前206)时已用不同硬度的毛和竹管制笔:汉代(前206—公元220) ...

  7. VPN有什么用?(转载)

    VPN有什么用?转载自:http://www.chinaz.com/web/2012/0320/240819.shtml 当你非常非常想访问一个国外的网站,而这个网站被防火墙屏蔽的时候,你应该怎么做呢 ...

  8. VPN理论简单介绍(转载)

    标签:VPN理论简单介绍 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://lvnian.blog.51cto.com/715528 ...

  9. Ahjesus获取自定义属性Attribute或属性的名称

    1:设置自己的自定义属性 public class NameAttribute:Attribute { private string _description; public NameAttribut ...

随机推荐

  1. java.lang.IllegalStateException: No instances available for localhost

    在SpringCloud的项目中,我们使用了自动配置的OAuth2RestTemplate,RestTemplate,但是在使用这些restTemplate的时候,url必须是服务的名称,如果要调用真 ...

  2. CSS中的那点事儿(一)--- CSS中的单位1

    单位主要用在规定元素的数值性css属性的,这里主要讨论应用的比较多的是width height  padding margin font-size,而单位中应用最广泛就是%.px.em 百分比 百分比 ...

  3. Dedecms(织梦)文章内容页和图片集内容页,调用缩略图的方法

    Dedecms(织梦)文章内容页和图片集内容页,调用缩略图的方法,亲测可用! Dedecms(织梦)首页的图片调用,相信大家已经非常的清楚,但是今天我在进行内容页的编写的时候,发现了内容页图片的调用问 ...

  4. stringBuffer、StringBuilder、排序、Arrays、Jdk1.5新特性(java基础知识十三)

    1.StringBuffer类的概述 * A:StringBuffer类概述 * 通过JDK提供的API,查看StringBuffer类的说明 * 1.线程安全的可变字符序列. * 2.可将字符串缓冲 ...

  5. codevs矩阵乘法系列

    T1:矩阵乘法板子题,练手. #include <map> #include <set> #include <cmath> #include <ctime&g ...

  6. Vue安装及插件Vue Devtools

    vue安装: # 最新稳定版 $ npm install vue # 全局安装 vue-cli $ npm install --global vue-cli # 创建一个基于 webpack 模板的新 ...

  7. 多线程-threading模块3

    超级播放器 #coding:utf-8 import threading from time import sleep,ctime #超级播放器 def super_player(file,time) ...

  8. Hackerearth: Mathison and the Pokémon fights

    Mathison and the Pokémon fights code 这是一道比较有意思,出的也非常好的题目. 给定$n$个平面上的点$(x_i, y_i)$,(允许离线地)维护$Q$个操作:1. ...

  9. 用文件作为Swap分区

    用文件作为Swap分区 1.创建要作为swap分区的文件:增加1GB大小的交换分区,则命令写法如下,其中的count等于想要的块的数量(bs*count=文件大小).# dd if=/dev/zero ...

  10. FTP相关内容

    FTP相关介绍 FTP 1)File Transfer Protocol ( FTP ) 是相当古老的网络协议之一,他最主要的功能就是进行 Server端与 Client 端之间的档案传送的功能.这个 ...