bzoj3382[usaco2004 Open]cave Cows 3 The three cows in the cave
Test instructions
n points, finding the farthest Manhattan distance. n≤50000.
Exercises
Manhattan distance to the Chebyshev distance (point (x, Y) to point (X+y,x-y)), and then output the maximum horizontal axis-minimum horizontal and maximum ordinate-minimum ordinate the larger value.
Code:
1#include <cstdio>2#include <cstring>3#include <algorithm>4 #defineInc (I,J,K) for (int i=j;i<=k;i++)5 #defineMAXN 500106 #defineINF 0X3FFFFFFF7 using namespacestd;8 9InlineintRead () {Ten CharCh=getchar ();intf=1, x=0; One while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; Ch=GetChar ();} A while(ch>='0'&&ch<='9') x=x*Ten+ch-'0', ch=GetChar (); - returnf*x; - } the intx[maxn],y[maxn],n,ans,mx,mn; - intMain () { -N=read (); Inc (I,1, N) {intA=read (), B=read (); X[i]=a+b; Y[i]=a-b;} ans=0; -Mx=-inf; Mn=inf; Inc (I,1, N) Mx=max (Mx,x[i]), Mn=min (Mn,x[i]); Ans=max (ans,mx-mn); +Mx=-inf; Mn=inf; Inc (I,1, N) Mx=max (Mx,y[i]), Mn=min (Mn,y[i]); Ans=max (ans,mx-mn); -printf"%d", ans);return 0; +}
20160912
bzoj3382[usaco2004 Open]cave Cows 3 The three cows in the cave