codeforce 605BE. Freelancer's Dreams
题意:给你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的更多相关文章
- CF#335 Freelancer's Dreams
Freelancer's Dreams time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 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 ...
- Codeforces 605C Freelancer's Dreams 凸包 (看题解)
Freelancer's Dreams 我们把每个二元组看成是平面上的一个点, 那么两个点的线性组合是两点之间的连线, 即x * (a1, b1) + y * (a1, b1) && ...
- 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有 ...
- [CodeForces-606E] Freelancer's Dreams 凸包 模型转换
大致题意: 有一个人想要获得p个经验点和q元钱.现在给出n份工作,每份工作每天能得到Ai的经验值和Bi的钱,问最少需要工作多少天, 能使得总经验值>=p,总钱>=q. 先对给出的n份工作以 ...
- 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 ...
- Codeforce - Street Lamps
Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...
- Codeforce Round #216 Div2
e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头 ...
- Codeforce 水题报告(2)
又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数( ...
随机推荐
- 增强LSH
通过LSH hash functions我们能够得到一个或多个hash table,每个桶内的数据之间是近邻的可能性很大.我们希望原本相邻的数据经过LSH hash后,都能够落入到相同的桶内,而不相邻 ...
- [转载]在網頁上加入HTML5 的Video Tag,直接播放MP4、OGG…等
在之前有一篇文章提到HTML5(為何iPhone,iPod,iPad不支援Flash,HTML5將更普及於網路世界!!)的重要性,而Html 5的主要革新是在他的語意標籤,像是<video> ...
- EasyUI Datagrid 取编辑修改后的内容
<script type="text/javascript"> $(function () { $('#tt').datagrid({ iconCls: 'icon-e ...
- sequel 连接不上,命令行能连上
Sequel pro won't connect anymore I'm running into some trouble right now. I worked yesterday on my d ...
- Java中堆、栈、常量池分析
栈用于存储局部变量,包括基本类型的变量(方法语句块内部定义的变量.方法中的形参).引用类型的变量,它们都是存储在各自的方法栈中,随着方法的执行完成而消失: 堆用于存储引用类型变量所指向的对象,包括普通 ...
- Docker 监控实战
如今,越来越多的公司开始使用 Docker 了,现在来给大家看几组数据: 2 / 3 的公司在尝试了 Docker 后最终使用了它 也就是说 Docker 的转化率达到了 67%,而转化市场也控制在 ...
- Linux防火墙iptables简明教程
前几天微魔部落再次遭受到个别别有用心的攻击者的攻击,顺便给自己充个电,复习了一下linux下常见的防火墙iptables的一些内容,但是无奈网上的很多教程都较为繁琐,本着简明化学习的目的,微魔为大家剔 ...
- POJ2506——Tiling
Tiling Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a samp ...
- Spring RestTemplate介绍
http://www.cnblogs.com/rollenholt/p/3894117.html RestTemplate 这篇文章打算介绍一下Spring的RestTemplate.我这边以前设计到 ...
- 概率图模型之有向图与无向图之间的关系 I map D map perfect map(完美图) 概念
我们已经讨论了有向图和无向图框架下的概率模型,那么我们有必要讨论一下它们二者的关系.