Test instructions: Give the value of the three-line d, respectively, there are two teams, if less than or equal to D, 2 points, if greater than D, three points, asked to make a-B max
As soon as I see the title, I take it for granted that----nothing.---55555555
Only later know can not be two points, because with the increase of D, two teams will gradually reduce the score, but two teams of the difference in the value of the monotony but do not know
This is the http://www.cnblogs.com/huangxf/p/4142760.html of this story.
Then enumerate the values of D in turn, maintaining a maximum value
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <stack>6#include <vector>7#include <map>8#include <Set>9#include <queue>Ten#include <algorithm> One using namespacestd; A -typedefLong LongLL; - Const intINF = (1<< -)-1; the Const intMod=1000000007; - Const intmaxn=1000005; - - intn,m; + intA[MAXN],B[MAXN],C[MAXN]; - + intMain () { A intCnt=0; atc[++cnt]=0; -scanf"%d",&n); - for(intI=0; i<n;i++) scanf ("%d", &a[i]), c[++cnt]=A[i]; -scanf"%d",&m); - for(intI=0; i<m;i++) scanf ("%d", &b[i]), c[++cnt]=B[i]; - inSort (a,a+n); -Sort (b,b+m); toSort (c,c+CNT); + inttmp=-Inf,l,r; - the intLb,ub; * for(intI=1; i<=cnt;i++){ $ intX=upper_bound (A,a+n,c[i])-A;Panax Notoginseng intY=upper_bound (B,b+m,c[i])-b; - theLB = x*2+ (n-x) *3; +UB = y*2+ (m-y) *3; A if(Lb-ub >tmp) { thetmp=lb-UB; +l=lb; R=UB; - } $ if(Lb-ub = = tmp && lb > L) L =lb; $ } -printf"%d:%d\n", l,r); - return 0; the}
View Code
Codeforces 493 C Vasya and Basketball