5 August
P1016 旅行家的预算
单调队列。
再看看单调队列怎么用的。
#include <cstdio>
int n, l, r;
double D, dd, d[9], C, p[9], ans;
struct node{
double t, x;
} q[999];
int main() {
scanf("%lf%lf%lf%lf%d", &D, &C, &dd, &p[0], &n); d[0]=0;
for (int i=1; i<=n; ++i) {
scanf("%lf%lf", &d[i], &p[i]);
if (d[i]-d[i-1]>C*dd) {printf("No Solution\n"); return 0; }
}
d[n+1]=D; double now=0.0;
q[++r]=(node){p[0], now=C}, ans+=p[0]*C;
for (int i=1; i<=n+1; ++i) {
double cos=(d[i]-d[i-1])/dd;
while (l<=r && cos>0) {
if (q[l].x>cos) {now-=cos, q[l].x-=cos; break; }
now-=q[l].x, cos-=q[l].x; ++l;
}
if (i==n+1) {
while (l<=r) ans-=q[l].t * q[l].x, ++l; break;
}
while (l<=r && q[r].t>p[i]) {
ans-=q[r].t*q[r].x, now-=q[r].x; --r;
}
ans+=(C-now)*p[i];
q[++r]=(node){p[i], C-now}; now=C;
}
printf("%.2lf\n", ans);
return 0;
}
5 August的更多相关文章
- Monthly Income Report – August 2016
原文链接:https://marcoschwartz.com/monthly-income-report-august-2016/ Every month, I publish a report of ...
- [ZZ]Sign Up for the First-Ever Appium Roadshow on August 20th in New York City
http://sauceio.com/index.php/2014/07/appium-roadshow-nyc/?utm_source=feedly&utm_reader=feedly&am ...
- 浙大月赛ZOJ Monthly, August 2014
Abs Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Alice and Bob is playing a ga ...
- [转载]ECMA-262 6th Edition / Draft August 24, 2014 Draft ECMAScript Language Specification
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-23.4 Draft Report Errors and Issues at: htt ...
- 135 - ZOJ Monthly, August 2014
135 - ZOJ Monthly, August 2014 A:构造问题,推断序列奇偶性.非常easy发现最小值不是1就是0.最大值不是n就是n - 1,注意细节去构造就可以 E:dp.dp[i][ ...
- git -remote: Support for password authentication was removed on August 13, 2021
克隆代码时,报错: Support for password authentication was removed on August 13, 2021. Please use a personal ...
- August 31st 2016 Week 36th Tuesday
A friend without faults will never be found. 没有缺点的朋友是永远找不到的. You can't find a friends without faults ...
- August 30th 2016 Week 36th Tuesday
If you keep on believing, the dreams that you wish will come true. 如果你坚定信念,就能梦想成真. I always believe ...
- August 29th 2016 Week 36th Monday
Every has the capital to dream. 每个人都有做梦的本钱. Your vision, our mission. That is an advertisment of UMo ...
- August 28th 2016 Week 36th Sunday
What doesn't kill you makes you stronger. 那些没有彻底击败你的东西只会让你更强大. Where there is life, there is hope, a ...
随机推荐
- WCF权限认证多种方式
WCF身份验证一般常见的方式有:自定义用户名及密码验证.X509证书验证.ASP.NET成员资格(membership)验证.SOAP Header验证.Windows集成验证.WCF身份验证服务(A ...
- (转载)Spring与SpringMVC父子容器的关系与初始化
转自 https://blog.csdn.net/dhaiuda/article/details/80026354 Spring和SpringMVC的容器具有父子关系,Spring容器为父容器,Spr ...
- docker安装及基本命令
Ubuntu安装docker sudo apt-get install docker.io Centos安装docker # 更新系统软件包 yum -y upgrade # 官方下载地址 curl ...
- 04 - Jmeter4.x聚合报告,测试报告以及测试报告用法于解析
聚合报告 添加方式 Thread Group → add → Listener → Aggregate Report 内容解析 lable: 指代当前Samples ...
- 性能测试工具 Jmeter GET 请求 参数为 Json 串且参数中存在变量的转化
2.在BeanShell PreProcessor的实现:
- from、includes、indexOf
from.includes.indexOf:https://blog.csdn.net/j59580/article/details/53897630?utm_source=blogxgwz1 语法 ...
- LOJ 2234/BZOJ 3629 聪明的燕姿(数论+DFS)
题面 传送门 分析 看到约数之和,我们首先想到约数和公式 若$ x=\prod_{i=1}^{n}p_i^{k_i} \(,则x的约数和为\) \prod_{i=1}^{n} \sum_{j=0}^{ ...
- ubuntu18.04 搭建scrapy环境(连环踩坑+解决办法)
---恢复内容开始--- 预期需求: 打算搭建scrapy环境,基于python3.x的 环境描述: ubuntu18.04自带了python3.6,打算在虚拟环境vlenv中跑scrapy,装好虚拟 ...
- 广播模式下的生产者与消费者fanout模式
生产者 #coding=utf-8 import pika import sys connection = pika.BlockingConnection(pika.ConnectionParamet ...
- Java 8实战之读书笔记五:超越Java 8
四.超越Java 8 第13章 函数式的思考 下面是这一章中你应该掌握的关键概念. 从长远看,减少共享的可变数据结构能帮助你降低维护和调试程序的代价. 函数式编程支持无副作用的 ...