题意:给你n个工程,做了每个工程相应增长x经验和y钱。问你最少需要多少天到达制定目标。时间可以是浮点数。

思路:杜教思路,用对偶原理很简易。个人建议还是标准解题法,凸包+线性组合。

 #include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
#include <bits/stdc++.h>
using namespace std;
#define CL(x,v); memset(x,v,sizeof(x));
#define INF 0x3f3f3f3f
#define LL long long
const int SIGMA_SIZE = ;
const int MAXNODE = ;
const int MAXS = + ;
const int maxn = 1e5+;
int a[maxn], b[maxn];
int n, p, q; double f(double x)
{
double y = ;
for(int i=;i<n;i++) y = min(y, (1.0 - x*b[i]) / a[i]);
return y*p + x*q;
} int main()
{
cin >> n >> p >> q;
for(int i=;i<n;i++) cin >> a[i] >> b[i];
double l=, r = ./ (*max_element(b, b+n));
for(int i=;i<;i++)
{
double ll = (l+l+r)/, rr = (r + r+l)/;
if(f(ll) > f(rr)) r = rr;
else l = ll;
}
printf("%.10f\n", f((l+r)*0.5));
return ;
}

codeforce 605BE. Freelancer's Dreams的更多相关文章

  1. CF#335 Freelancer's Dreams

    Freelancer's Dreams time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #335 (Div. 1) C. Freelancer's Dreams 计算几何

    C. Freelancer's Dreams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contes ...

  3. Codeforces 605C Freelancer's Dreams 凸包 (看题解)

    Freelancer's Dreams 我们把每个二元组看成是平面上的一个点, 那么两个点的线性组合是两点之间的连线, 即x * (a1, b1) + y * (a1, b1) && ...

  4. Codeforces Round #335 (Div. 1)--C. Freelancer's Dreams 线性规划对偶问题+三分

    题意:p, q,都是整数. sigma(Ai * ki)>= p, sigma(Bi * ki) >= q; ans = sigma(ki).输出ans的最小值 约束条件2个,但是变量k有 ...

  5. [CodeForces-606E] Freelancer's Dreams 凸包 模型转换

    大致题意: 有一个人想要获得p个经验点和q元钱.现在给出n份工作,每份工作每天能得到Ai的经验值和Bi的钱,问最少需要工作多少天, 能使得总经验值>=p,总钱>=q. 先对给出的n份工作以 ...

  6. reborn to freelancer

    I want to be a freelancer, so I come back to record all my efforts. I hope this will be a new start ...

  7. Codeforce - Street Lamps

    Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...

  8. Codeforce Round #216 Div2

    e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...

  9. Codeforce 水题报告(2)

    又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数( ...

随机推荐

  1. JavaScript中创建字典对象(dictionary)实例

    这篇文章主要介绍了JavaScript中创建字典对象(dictionary)实例,本文直接给出了实现的源码,并给出了使用示例,需要的朋友可以参考下 对于JavaScript来说,其自身的Array对象 ...

  2. YUV格式详解

    What is YUV YUV,是一种颜色编码方法. YUV是编译true-color颜色空间(color space)的种类,Y'UV, YUV, YCbCr,YPbPr等专有名词都可以称为YUV, ...

  3. eclipse颜色配置

    Eclipse颜色主题插件:Eclipse Color Theme http://blog.sina.com.cn/s/blog_674212810101go8x.html 一个很赞的eclipse插 ...

  4. 关于CreadThread()与CloseHandle()

    今天看了点关于Windows多线程的东西,摘抄点关于CloseHandle的内容放于此,以便以后参考. 主要是<Windows核心编程>里的两小节: 3.1.1 内核对象的使用计数     ...

  5. android 安全需要关注

    1.通过签名校验保护,能有效避免应用被二次打包,杜绝盗版应用的产生2.对内存数据进行变换处理和动态跟踪,有效防止数据被获取和修改3.对代码进行加密压缩,可防止破解者还原真实代码逻辑,避免被复制4.多重 ...

  6. C++不同进制整数

    在C++的整数常量中,整数分为十进制整数.八进制整数和十六进制整数. 那给出一个整型常量怎样区分是何种进制呢?/给出一个整型常量,如100,默认是十进制数,如果在该数前加0,如0100,则此数表示为八 ...

  7. JVM运行机制

    JVM启动流程

  8. RxJava学习(三)

    变换 所谓变换,就是将事件序列中的对象或整个序列进行加工处理,转换成不同的事件或事件序列. 1) API 首先看一个 map() 的例子: Observable.just("images/l ...

  9. 【HDOJ】4775 Infinite Go

    其实是一道模拟题,并查集用来优化.还可以的一道题目. /* 4775 */ #include <iostream> #include <sstream> #include &l ...

  10. oracle时间加减的语句写法

    FROM: http://soft.doit.com.cn/article/2012/0105/2850851.shtml --加法 --加1年  SELECT SYSDATE,ADD_MONTHS( ...