Test instructions: give you n a project, do each project corresponding growth x experience and y money. Ask how many days you need to arrive at least to set goals. The time can be a floating-point number.
Train of thought: the idea of du teaching, with dual principle is very simple. Personal advice is also a standard solution, convex hull + linear combination.
1#include <iostream>2#include <string>3#include <algorithm>4#include <cstdlib>5#include <cstdio>6#include <Set>7#include <map>8#include <vector>9#include <cstring>Ten#include <stack> One#include <cmath> A#include <queue> -#include <bits/stdc++.h> - using namespacestd; the #defineCL (X,V); memset (x,v,sizeof (x)); - #defineINF 0x3f3f3f3f - #defineLL Long Long - Const intSigma_size = -; + Const intMaxnode =111000; - Const intMaxs = Max+Ten; + Const intMAXN = 1e5+Ten; A intA[MAXN], B[MAXN]; at intN, p, q; - - DoubleFDoublex) - { - Doubley =1; - for(intI=0; i<n;i++) y = min (Y, (1.0-x*b[i])/a[i]); in returnY*p + x*Q; - } to + intMain () - { theCIN >> n >> P >>Q; * for(intI=0; i<n;i++) cin >> A[i] >>B[i]; $ DoubleL=0, r =1./(*max_element (b, + +n));Panax Notoginseng for(intI=0;i< $; i++) - { the Doublell = (l+l+r)/3, rr = (R + r+l)/3; + if(f (LL) > F (RR)) R =RR; A ElseL =ll; the } +printf"%.10f\n", F ((l+r) *0.5)); - return 0; $}
View Code
Codeforce 605BE. Freelancer ' s Dreams