poj1857 To Europe! To Europe!
思路:
一维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!的更多相关文章
- Fedora 22中的日期和时间配置
Introduction Modern operating systems distinguish between the following two types of clocks: A real- ...
- Windows Azure Storage (17) Azure Storage读取访问地域冗余(Read Access – Geo Redundant Storage, RA-GRS)
<Windows Azure Platform 系列文章目录> 细心的用户会发现,微软在国外和国内的数据中心建设都是成对的,比如香港数据中心(Asia East)和新加坡的数据中心(Sou ...
- android时区
<timezones> <timezone id="Pacific/Majuro">马朱罗</timezone> <timez ...
- shell 脚本样例
1 解压文件,移动文件,删除特定目录 #!/bin/bash pa=$(cd ``; pwd) //获得当前目录的绝对路径 v_dir=${pa} mkdir ${v_dir} dirDist=${ ...
- 使用celery之深入celery配置(转)
原文:http://www.dongwm.com/archives/shi-yong-celeryzhi-shen-ru-celerypei-zhi/ 前言 celery的官方文档其实相对还是写的很不 ...
- Chinese culture
文房四宝 笔墨纸砚是中国古代文人书房中必备的宝贝,被称为“文房四宝”.用笔墨书写绘画在 中国可追溯到五千年前.秦(前221---前206)时已用不同硬度的毛和竹管制笔:汉代(前206—公元220) ...
- VPN有什么用?(转载)
VPN有什么用?转载自:http://www.chinaz.com/web/2012/0320/240819.shtml 当你非常非常想访问一个国外的网站,而这个网站被防火墙屏蔽的时候,你应该怎么做呢 ...
- VPN理论简单介绍(转载)
标签:VPN理论简单介绍 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://lvnian.blog.51cto.com/715528 ...
- Ahjesus获取自定义属性Attribute或属性的名称
1:设置自己的自定义属性 public class NameAttribute:Attribute { private string _description; public NameAttribut ...
随机推荐
- HDU1693 Eat the Trees —— 插头DP
题目链接:https://vjudge.net/problem/HDU-1693 Eat the Trees Time Limit: 4000/2000 MS (Java/Others) Mem ...
- Elasticsearch分布式安装启动失败
配置config目录下的 elasticsearch.yml http.cors.enabled: true http.cors.allow-origin: "*" #分布安装. ...
- codeforces 691C C. Exponential notation(科学计数法)
题目链接: C. Exponential notation time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- Servlet的HelloWorld
设置好TOMCAT环境变量(如何设置?)后在命令行输入startup可以启动Tomcat,输入shutdown可以关闭Tomcat. /WEB-INF/web.xml是称为部署描述器的配置文件,Jav ...
- python整数与IP地址转换 [转]
我们有时会将一个整数与IP地址进行互换,用python代码实现很简单将一个整数如2000000,变为一个IP地址的方式 >>> import socket >>> ...
- 【197】PowerShell 通过 FTP 下载文件
参考:使用 WGET 从FTP上下载文件 在 PowerShell 使用 wget2 工具,代码如下: wget2 ftp://user:password@192.168.14.31/1.jpg 其中 ...
- excel中需要熟练掌握技能
一.排版篇: 给他人发送excel前,请尽量将光标定位在需要他人首先阅览的位置,例如Home位置(A1),例如结论sheet,长表尽量将位置定位到最顶端 有必要的时候请冻结首行:没必要但可追究的内容, ...
- HDU-5538 House Building
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submissio ...
- 1004 n^n的末位数字
题目来源: Author Ignatius.L (Hdu 1061) 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 给出一个整数N,输出N^N(N的N次方)的十 ...
- 记一次OutOfMemory定位过程
背景 最近有个项目部署到了AWS,部署方案是ECS+Docker+Java Launch type CPU Units Memory FARGATE 1024 4G 运行后发现程序表现不符合预期--每 ...