Problem:


Score : 500 points

Problem Statement

There are N points on the 2D plane, i-th of which is located on (x_i, y_i).
There can be multiple points that share the same coordinate.
What is the maximum possible Manhattan distance between two distinct points?

Here, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-y_j|.

Constraints

2 \leq N \leq 2 \times 10^5

1 \leq x_i,y_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
x_2 y_2
:
x_N y_N

Output

Print the answer.

Sample Input 1

3
1 1
2 4
3 2

Sample Output 1

4

The Manhattan distance between the first point and the second point is |1-2|+|1-4|=4, which is maximum possible.

Sample Input 2

2
1 1
1 1

Sample Output 2

0



Sample input:
3
1 1
2 4
3 2


Sample output:
4

Submission status: Wrong Answer

Solution code:
N=int(input())
numbers=[]
for _ in range(N):
    x,y=map(int,input().split())
    numbers.append([x,y])
saishou=[numbers[0][0],numbers[0][1]]
saidai=[numbers[0][0],numbers[0][1]]
min_dis=numbers[0][0]**2+numbers[0][1]**2
max_dis=numbers[0][0]**2+numbers[0][1]**2
for num in numbers:
    if num[0]**2+num[1]**2<min_dis:
        min_dis=num[0]**2+num[1]**2
        saishou=[num[0],num[1]]
    if num[0]**2+num[1]**2>max_dis:
        max_dis=num[0]**2+num[1]**2
        saidai=[num[0],num[1]]
ans1=saidai[0]-saishou[0]+saidai[1]-saishou[1]
sort_numbers=sorted(numbers)
max_x=sort_numbers[-1][0]
for n in range(N):
    numbers[n]=[numbers[n][0]-max_x,numbers[n][1]]
saishou=[numbers[0][0],numbers[0][1]]
saidai=[numbers[0][0],numbers[0][1]]
min_dis=numbers[0][0]**2+numbers[0][1]**2
max_dis=numbers[0][0]**2+numbers[0][1]**2
for num in numbers:
    if num[0]**2+num[1]**2<min_dis:
        min_dis=num[0]**2+num[1]**2
        saishou=[num[0],num[1]]
    if num[0]**2+num[1]**2>max_dis:
        max_dis=num[0]**2+num[1]**2
        saidai=[num[0],num[1]]
ans2=abs(saidai[0]-saishou[0])+abs(saidai[1]-saishou[1])
print(max(ans1,ans2))

Submission status: Wrong Answer

Solution code:
N=int(input())
minz=10**11
minw=10**11
maxz=0
maxw=0
for i in range(N):
 
    a,b=map(int,input().split())
    if  a+b>maxz:
        maxz=a+b

    if a+b<minz:
        minz=a+b

    if  a-b>maxw:
        maxw=a-b

    if a-b<minw:
        minw=a-b

    
 
print(max((maxz-minz),(maxw-minw)))

Submission status: Wrong Answer

Solution code:
N=int(input())
minz=10**11
minw=10**11
maxz=0
maxw=0
for i in range(N):
 
    a,b=map(int,input().split())
    if  a+b>maxz:
        maxz=a+b

    if a+b<minz:
        minz=a+b

    if  abs(a-b)>maxw:
        maxw=abs(a-b)

    if abs(a-b)<minw:
        minw=abs(a-b)

    
 
print(max((maxz-minz),(maxw-minw)))

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = []
for _ in range(n):
    x, y = map(int, input().split())
    lst.append([x+y, x, y])

lst.sort()
print(lst[-1][0] - lst[0][0])

Submission status: Wrong Answer

Solution code:
n = int(input())
maxx, minx, maxy, miny = -1**10, 1**10, -1**10, 1**10
for _ in range(n):
	x, y = map(int, input().split())
	x, y = x+y, x-y
	maxx = max(maxx, x)
	minx = min(minx, x)
	maxy = max(maxy, y)
	miny = min(miny, y)
print(max(maxx - minx, maxy - miny))

Submission status: Wrong Answer

Solution code:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)

    D = 16
    x1 = y1 = 10**9+1
    x2 = y2 = 0
    vis = set()
    for xy in zip(it, it):
        if xy in vis:
            continue
        vis.add(xy)
        x, y = xy
        x1 = min(x1, x); x2 = max(x2, x)
        y1 = min(y1, y); y2 = max(y2, y)
    dd = max(1, (x2-x1) // D, (y2-y1) // D)
    dx = (x2-x1+1)//dd + 1
    dy = (y2-y1+1)//dd + 1
    d = [[[] for j in range(dx)] for i in range(dy)]


    md = [[] for i in range(dx+dy-1)]
    for i in range(dx*dy):
        ay1, ax1 = divmod(i, dx)
        md[0].append((ax1, ay1, ax1, ay1))
        for j in range(i+1, dx*dy):
            ay2, ax2 = divmod(j, dx)
            md[abs(ax1-ax2)+abs(ay1-ay2)].append((ax1, ay1, ax2, ay2))

    for xy in vis:
        x, y = xy
        ix = (x-x1) // dd
        iy = (y-y1) // dd
        d[iy][ix].append(xy)

    ans = 0
    for md1 in reversed(md):
        for x1, y1, x2, y2 in md1:
            if len(d[y2][x2]) == 0:
                continue

            for xx1, yy1 in d[y1][x1]:
                for xx2, yy2 in d[y2][x2]:
                    val = abs(xx1-xx2) + abs(yy1-yy2)

                    ans = max(ans, val)
        if ans:
            break
    print(ans)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def LI():
    return list(map(int, input().split()))


pu = []
mi = []
N = int(input())
for _ in range(N):
    x, y = LI()
    pu.append(x+y)
    mi.append(x-y)
P = max(pu)
p = min(pu)
M = max(mi)
m = max(mi)
print(max(P-p, M-m))

Submission status: Wrong Answer

Solution code:
import math
N = int(input())

s1 = []
s2 = []
#visited
for i in range(N):
    x, y = map(int, input().split())
    d0 = x + y
    d1 = x - y
    if d0 in s1 and d1 in s2 and s1.index(d0) == s2.index(d1):
        continue
    s1.append(d0)
    s2.append(d1)


ans = 0

if len(s1) > 1 and len(s2) > 1:
    s1s = sorted(s1)
    s2s = sorted(s2)

    ans = max(s1s[0] - s1s[-1], (s2s[0] - s2s[-1])
              , (s1s[0] - s2s[0]), (s1s[-1] - s2s[-1]))

print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
N = int(input())

s1 = []
s2 = []
#visited
for i in range(N):
    x, y = map(int, input().split())
    d0 = x + y
    d1 = x - y
    if d0 in s1 and d1 in s2 and s1.index(d0) == s2.index(d1):
        continue
    s1.append(math.fabs(d0))
    s2.append(math.fabs(d1))


ans = 0

if len(s1) > 1 and len(s2) > 1:
    s1s = sorted(s1)
    s2s = sorted(s2)

    ans = max(s1s[0] - s1s[-1], (s2s[0] - s2s[-1])
              , (s1s[0] - s2s[0]), (s1s[-1] - s2s[-1]))

print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
M = [list(map(int, input().split())) for _ in range(N)]

s = []
l = []
top = 2*(10**9)
low = 0
for j in range(N):
    t = sum(M[j])
    if low == t:
        s.append(M[j])
    elif low < t:
        low = t
        s = []
        s.append(M[j])

    if top == t:
        l.append(M[j])
    elif top > t:
        top = t
        l = []
        l.append(M[j])
if not s:
    s.append(M[0])
if not l:
    l.append(M[0])


def cal_man(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


s.sort()
l.sort()
print(max([cal_man(s[0], l[-1]), cal_man(s[-1], l[0])]))

Submission status: Wrong Answer

Solution code:
N = int(input())
M = [list(map(int, input().split())) for _ in range(N)]

s = []
l = []
top = sum(M[0])
low = top
for j in range(1, N):
    t = sum(M[j])
    if low <= t:
        low = t
        s.append(M[j])
    if top >= t:
        top = t
        l.append(M[j])
if not s:
    s.append(M[0])
if not l:
    l.append(M[0])


def cal_man(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


print(max([cal_man(s[0], l[-1]), cal_man(s[-1], l[0])]))

Submission status: Wrong Answer

Solution code:
N = int(input())
M = [list(map(int, input().split())) for _ in range(N)]

s = []
l = []
top = sum(M[0])
low = top
for j in range(N):
    t = sum(M[j])
    if low <= t:
        low = t
        s.append(M[j])
    if top >= t:
        top = t
        l.append(M[j])
if not s:
    s.append(M[0])
if not l:
    l.append(M[0])


def cal_man(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


ans = 0
for S in s:
    for L in l:
        man = cal_man(S, L)
        if man > ans:
            ans = man
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
M = [list(map(int, input().split())) for _ in range(N)]

s = []
l = []
top = sum(M[0])
low = top
for j in range(N):
    t = sum(M[j])
    if top < t:
        top = t
        s.append(M[j])
    if low > t:
        low = t
        l.append(M[j])
if not s:
    s.append(M[0])
if not l:
    l.append(M[0])


def cal_man(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


ans = 0
for S in s:
    for L in l:
        man = cal_man(S, L)
        if man > ans:
            ans = man
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

#二分探索
#l:ソート済リスト s:検索する値
#s以上の値をとる最小のindexが返る
def nibuntansaku(l,s,j):
    def check(L,i):
        if L[i][j] > s:
            return True
        else:
            return False

    left = -1 #False側
    right =len(l)-1 #True側

    while right -left > 1:
        mid = (left + right)//2
        if check(l,mid):
            right =mid
        else:
            left =mid
    return right

N = int(input())

def d(l1,l2):
    return abs(l1[0]-l2[0])+abs(l1[1]-l2[1])

l = [[int(i)for i in input().split()] for _ in range(N)]

l.sort(key=lambda x:x[1])
l.sort(key=lambda x:x[0])

rlis = []
rlis.append(l[0])
rlis.append(l[-1])

l.sort(key=lambda x:x[1])
rlis.append(l[0])
rlis.append(l[-1])

l.sort(key=lambda x:x[0],reverse=True)
rlis.append(l[0])
rlis.append(l[-1])

l.sort(key=lambda x:x[1])
rlis.append(l[0])
rlis.append(l[-1])

ans = 0
for r in rlis:
    tmp = 0
    for s in l:
        tmp = max(tmp,d(r,s))
    ans = max(ans,tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
b=[]
for i in range(n):
    x,y=list(map(int,input().split()))
    a.append(x+y)
    b.append(x-y)
print(abs(max(max(a),max(b)))-abs(min(min(a),min(b))))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    x,y=list(map(int,input().split()))
    a.append(x+y)

print(abs(max(a))-abs(min(a)))

Submission status: Wrong Answer

Solution code:
n = int(input())
zm = -2e10
zn = 30000000000
wm = -2e10
wn = 30000000000
while(n):
  x,y = map(int,input().split())
  zm = max(zm,x+y)
  zn = min(zn,x+y)
  wm = max(wm,x-y)
  wn = min(wn,x-y)
  n-=1
  
print(max(zm-zn,wm,wn))

Submission status: Wrong Answer

Solution code:
n = int(input())
zm = -1
zn = 10000000000
wm = -1
wn = 10000000000
while(n):
  x,y = map(int,input().split())
  zm = max(zm,x+y)
  zn = min(zn,x+y)
  wm = max(wm,x-y)
  wn = min(wn,x-y)
  n-=1
  
print(max(zm-zn,wm,wn))

Submission status: Wrong Answer

Solution code:
n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]
d=[]
for i in range(n):
  d.append([xy[i][0]+xy[i][1],xy[i][0],xy[i][1]])
d.sort()
print(abs(d[0][1]-d[-1][1])+abs(d[0][2]-d[-1][2]))

Submission status: Wrong Answer

Solution code:
n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]
d=[]
for i in range(n):
  d.append([xy[i][0]**2+xy[i][1]**2,xy[i][0],xy[i][1]])
d.sort()

print(abs(d[0][1]-d[-1][1])+abs(d[0][2]-d[-1][2]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for _ in range(n):
  x, y = map(int, input().split())
  a.append([x,y])

a.sort()
print(abs(a[0][0]-a[n-1][0])+abs(a[0][1]-a[n-1][1]))

Submission status: Wrong Answer

Solution code:
n = int(input())

zmax = 0
zmin = 10**10
wmax = 0
wmin = 10**10

for i in range(n):
    x, y = map(int, input().split())
    zref = x + y
    wref = x - y
    zmax = max(zmax, zref)
    zmin = min(zmin, zref)
    wmax = max(wmax, wref)
    wmin = min(wmin, wref)

ans = max(zmax - zmin, wmax - wmin)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

xmax = 0
xmin = 10**10
ymax = 0
ymin = 10**10

for i in range(n):
    x, y = map(int, input().split())
    refx = x + y
    refy = x - y
    xmax = max(xmax, refx)
    xmin = min(xmin, refx)
    ymax = max(ymax, refy)
    ymin = min(ymin, refy)

ans = max(xmax - xmin, ymax - ymin)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

xmax = 0
xmin = 2*10**9
ymax = 0
ymin = 2*10**9

for i in range(n):
    x, y = map(int, input().split())
    refx = x + y
    refy = x - y
    xmax = max(xmax, refx)
    xmin = min(xmin, refx)
    ymax = max(ymax, refy)
    ymin = min(ymin, refy)

ans = max(xmax - xmin, ymax - ymin)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding:UTF-8
import sys


def resultSur97(x):
    return x % (1000000000 + 7)


if __name__ == '__main__':
    # ------ 入力 ------#
    # 1行入力
    n = int(input())    # 数字
    # a = input()     # 文字列
    # aList = list(map(int, input().split()))     # スペース区切り連続数字
    # aList = input().split()     # スペース区切り連続文字列
    # aList = [int(c) for c in input()]   # 数字→単数字リスト変換

    # 定数行入力
    x = n
    # aList = [int(input()) for _ in range(x)] # 数字
    # aList = [input() for _ in range(x)] # 文字
    aList = [list(map(int, input().split())) for _ in range(x)]     # スペース区切り連続数字(行列)
    # aList = [input().split() for _ in range(x)]     # スペース区切り連続文字
    # aList = [[int(c) for c in input()] for _ in range(x)]   # 数字→単数字リスト変換(行列)

    # スペース区切り連続 数字、文字列複合
    # aList = []
    # for _ in range(x):
    #     aa, bb = input().split()
    #     a.append((int(aa), bb))

    # ------ 処理 ------#
    xsep = aList[0][0]
    ysep = aList[0][1]

    kouho = [[[xsep, ysep, 0] for _ in range(5)] for __ in range(4)]
    for i in range(len(aList)):
        x = aList[i][0]
        y = aList[i][1]
        disX = abs(x - xsep)
        disY = abs(y - ysep)
        disXY = disX + disY

        if x >= xsep:
            if y >= ysep:
                index = 0
            else:
                index = 1
        else:
            if y >= ysep:
                index = 2
            else:
                index = 3

        if disX > kouho[index][0][2]:
            kouho[index][0] = [x, y, disX]
        if disY > kouho[index][1][2]:
            kouho[index][1] = [x, y, disY]
        if disXY > kouho[index][2][2]:
            kouho[index][2] = [x, y, disXY]
        if disX < kouho[index][3][2]:
            kouho[index][3] = [x, y, disX]
        if disY < kouho[index][4][2]:
            kouho[index][4] = [x, y, disY]

    kouho2 = []
    disMax = 0
    for i in range(len(kouho)):
        for i2 in range(len(kouho[i])):
            if kouho[i][i2] != [-1, -1, -1]:
                kouho2.append(kouho[i][i2])

    for i in range(len(kouho2)):
        xy = kouho2[i]
        for j in range(len(kouho2)):
            xy2 = kouho2[j]
            dis = abs(xy[0] - xy2[0]) + abs(xy[1] - xy2[1])
            if dis > disMax:
                disMax = dis

    # ------ 出力 ------#
    print("{}".format(disMax))
    # if flg == 0:
    #     print("YES")
    # else:
    #     print("NO")

Submission status: Wrong Answer

Solution code:
n = int(input())

xmax = 0
xmin = 10**9
ymax = 0
ymin = 10**9

for i in range(n):
    x, y = map(int, input().split())
    refx = x + y
    refy = x - y
    xmax = max(xmax, refx)
    xmin = min(xmin, refx)
    ymax = max(ymax, refy)
    ymin = min(ymin, refy)

ans = max(xmax - xmin, ymax - ymin)
print(ans)

Submission status: Wrong Answer

Solution code:
# cook your dish here
import sys,math
try:sys.stdin,sys.stdout=open('input.txt','r'),open('out.txt','w')
except:pass
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt,log
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
# print('{:.3f}'.format(1),round(1.123456789,4))
# sys.setrecursionlimit(500000)
def lcm(a,b): return (a*b)//gcd(a,b)
def setbits(n):return bin(n).count('1')
def resetbits(n):return bin(n).count('0')
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r):
    num,den=1,1;r=min(n,n-r)
    for i in range(r):num*=(n-i);den*=(i+1)
    return num//den
def ncr_p(n, r, p):
    num,den=1,1;r=min(r,n-r)
    for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
    return (num * modinv(den,p)) % p
def isPrime(num) :
    if num<=1:return False
    if num==2 or n==3:return True
    if (num % 2 == 0 or num % 3 == 0) :return False
    m = int(num**0.5)+1
    for i in range(5,m,6):
        if (num % i == 0 or num % (i + 2) == 0) :return False
    return True
def bin_search(s, low, high, val):
    while low <= high:
        mid = low + (high - low) // 2;
        if s[mid] == val:return mid
        elif s[mid] < val:low = mid + 1
        else:high = mid - 1
    return -1
def sumofdigit(num):
    count=0;
    while num : count+=num % 10;num //= 10;
    return count;
def inputmatrix():
    r,c=iia();mat=[0]*r;
    for i in range(r):mat[i]=iia();
    return r,c,mat;
def prefix_sum(n,s):
    for i in range(1,n):s[i]+=s[i-1]
    return s;
def binomial(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0
def divisors(n):
    res = [];
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if i==n//i:res.append(i)
            else:res.append(i);res.append(n//i)
    return res;
#code here
n = int(input())
points=[]
for i in range(n):
    a,b=iia()
    points.append([a,b])
points.sort(key=lambda x:x[1])
print(abs(points[0][0]-points[-1][0])+abs(points[0][1]-points[-1][1]))

Submission status: Wrong Answer

Solution code:
# coding:UTF-8
import sys


def resultSur97(x):
    return x % (1000000000 + 7)


if __name__ == '__main__':
    # ------ 入力 ------#
    # 1行入力
    n = int(input())    # 数字
    # a = input()     # 文字列
    # aList = list(map(int, input().split()))     # スペース区切り連続数字
    # aList = input().split()     # スペース区切り連続文字列
    # aList = [int(c) for c in input()]   # 数字→単数字リスト変換

    # 定数行入力
    x = n
    # aList = [int(input()) for _ in range(x)] # 数字
    # aList = [input() for _ in range(x)] # 文字
    aList = [list(map(int, input().split())) for _ in range(x)]     # スペース区切り連続数字(行列)
    # aList = [input().split() for _ in range(x)]     # スペース区切り連続文字
    # aList = [[int(c) for c in input()] for _ in range(x)]   # 数字→単数字リスト変換(行列)

    # スペース区切り連続 数字、文字列複合
    # aList = []
    # for _ in range(x):
    #     aa, bb = input().split()
    #     a.append((int(aa), bb))

    # ------ 処理 ------#
    xsep = aList[0][0]
    ysep = aList[0][1]

    kouho = [[[xsep, ysep, 0] for _ in range(3)] for __ in range(4)]
    for i in range(len(aList)):
        x = aList[i][0]
        y = aList[i][1]
        disX = abs(x - xsep)
        disY = abs(y - ysep)
        disXY = disX + disY

        if x >= xsep:
            if y >= ysep:
                index = 0
            else:
                index = 1
        else:
            if y >= ysep:
                index = 2
            else:
                index = 3

        if disX > kouho[index][0][2]:
            kouho[index][0] = [x, y, disX]
        if disY > kouho[index][1][2]:
            kouho[index][1] = [x, y, disY]
        if disXY > kouho[index][2][2]:
            kouho[index][2] = [x, y, disXY]

    kouho2 = []
    disMax = 0
    for i in range(len(kouho)):
        for i2 in range(len(kouho[i])):
            if kouho[i][i2] != [-1, -1, -1]:
                kouho2.append(kouho[i][i2])

    for i in range(len(kouho2)):
        xy = kouho2[i]
        for j in range(len(kouho2)):
            xy2 = kouho2[j]
            dis = abs(xy[0] - xy2[0]) + abs(xy[1] - xy2[1])
            if dis > disMax:
                disMax = dis

    # ------ 出力 ------#
    print("{}".format(disMax))
    # if flg == 0:
    #     print("YES")
    # else:
    #     print("NO")

Submission status: Wrong Answer

Solution code:
N = int(input())
M0 = M1 = 0
m0 = m1 = float('inf')

for _ in range(N):
    x, y = map(int, input().split())
    M0 = max(M0, x - y)
    m0 = min(m0, x - y)
    M1 = max(M1, x + y)
    m1 = min(m1, x + y)

print(max(M0 - m0, M1 - m1))

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = []
for _ in range(n):
    x,y = map(int,input().split(' '))
    arr.append([x,y])
    
arr.sort(key = lambda x:x[0])
maxi = -1
for item in arr:
    a = abs(arr[0][1]-item[0]) + abs(arr[0][1]-item[1])
    maxi = max(maxi,a)
print(maxi)

Submission status: Wrong Answer

Solution code:
n = int(input())
max_x = max_y = 0
min_x = min_y = 5 * 10**9
for i in range(n):
    X, Y = map(int, input().split())
    x = X + Y
    y = X - Y
    max_x = max(max_x, x)
    max_y = max(max_y, y)
    min_x = min(min_x, x)
    min_y = min(min_y, y)
print(max(max_x - min_x, max_y - min_y))

Submission status: Wrong Answer

Solution code:
n = int(input())
max_x = max_y = 0
min_x = min_y = 10**9
for i in range(n):
    X, Y = map(int, input().split())
    x = X + Y
    y = X - Y
    max_x = max(max_x, x)
    max_y = max(max_y, y)
    min_x = min(min_x, x)
    min_y = min(min_y, y)
print(max(max_x - min_x, max_y - min_y))

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = []
for _ in range(n):
    x,y = map(int,input().split(' '))
    arr.append([x,y])
    
arr.sort(key = lambda x:x[0])
ans1 = abs(arr[0][0]-arr[-1][0]) + abs(arr[0][1] - arr[-1][1])

arr.sort(key = lambda x:x[1])
ans2 = abs(arr[0][0]-arr[-1][0]) + abs(arr[0][1] - arr[-1][1])

print(max(ans1,ans2))

Submission status: Wrong Answer

Solution code:
N = int(input())
Y_MAX = 0
Y_MIN = 1000000000000

for i in range(N):
    x, y = map(int, input().split())
    if abs(0 - x) + abs(y - 1000000000000) > Y_MAX:
        Y_MAX = abs(0 - x) + abs(y - 1000000000000)
    if abs(0 - x) + abs(y - 1000000000000) < Y_MIN:
        Y_MIN = abs(0 - x) + abs(y - 1000000000000)
  
print(Y_MAX - Y_MIN)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
tail = 0
head = float('inf')
for i in range(N):
    tail = max(tail, sum(A[i]))
    head = min(head, sum(A[i]))
ans_1 = tail - head

tmp_h, tmp_t = 0, 0
tail = A[i]
head = A[i]
for i in range(N):
    tail = A[i] if tmp_h < A[i][0]-A[i][1] else tail
    head = A[i] if tmp_t < A[i][1]-A[i][0] else head
    tmp_t = A[i][0]-A[i][1] if tmp_h < A[i][0]-A[i][1] else tmp_h
    tmp_h = A[i][1]-A[i][0] if tmp_t < A[i][1]-A[i][0] else tmp_t

ans_2 = abs(tail[0]-head[0]) + abs(tail[1]-head[1])
ans = max(ans_1, ans_2)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
tail = 0
head = float('inf')
for i in range(N):
    tail = max(tail, sum(A[i]))
    head = min(head, sum(A[i]))
ans_1 = tail - head

tmp_h, tmp_t = 0, 0
tail = A[i]
head = A[i]
for i in range(N):
    tail = A[i] if tmp_h < A[i][0]-A[i][1] else tail
    head = A[i] if tmp_t < A[i][1]-A[i][0] else head

ans_2 = abs(tail[0]-head[0]) + abs(tail[1]-head[1])
ans = max(ans_1, ans_2)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
tail = 0
head = float('inf')
for i in range(N):
    tail = max(tail, sum(A[i]))
    head = min(head, sum(A[i]))

ans = tail - head
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
x,y = map(int,input().split())
maxplus = x+y
minplus = x+y
maxminus = x-y
minminus = x-y
for i in range(n-1):
  x,y = map(int,input().split())
  if x+y > maxplus:
    maxplus = x+y
  elif x+y < minplus:
    minplus = x+y
  elif x-y > maxminus:
    maxminus = x-y
  elif x-y < minminus:
    minminus = x-y
print(max(maxplus-minplus,maxminus-minminus))

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N=int(input())
XY = []
xAve = 0
yAve = 0
for _ in range(N):
    x,y=map(int,input().split())
    if (x,y) not in XY:
        XY.append((x,y))
        xAve += x
        yAve += y
xAve = xAve//N
yAve = yAve//N
XYnorm = [0]*4
for x,y in XY:
    nX = x-xAve
    nY = y-yAve
    if nX>=0 and nY>0:#第1象限
        XYnorm[0]=max(XYnorm[0],nX+nY)
    if nX <0 and nY >=0:#第2象限
        XYnorm[1]=max(XYnorm[1],-nX+nY)
    if nX <=0 and nY <0:#第3象限
        XYnorm[2]=max(XYnorm[2],-nX-nY)
    if nX >0 and nY <=0:#第4象限
        XYnorm[3]=max(XYnorm[3],nX-nY)
print(int(max(XYnorm[2]+XYnorm[0],XYnorm[3]+XYnorm[1])))

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N=int(input())
XY = []
xAve = 0
yAve = 0
for _ in range(N):
    x,y=map(int,input().split())
    XY.append([x,y])
    xAve += x
    yAve += y
xAve = xAve/N
yAve = yAve/N
XYnorm = [0]*4
for x,y in XY:
    nX = x-xAve
    nY = y-yAve
    if nX>=0 and nY>0:#第1象限
        XYnorm[0]=max(XYnorm[0],nX+nY)
    if nX <0 and nY >=0:#第2象限
        XYnorm[1]=max(XYnorm[1],-nX+nY)
    if nX <=0 and nY <0:#第3象限
        XYnorm[2]=max(XYnorm[2],-nX-nY)
    if nX >0 and nY <=0:#第4象限
        XYnorm[3]=max(XYnorm[3],nX-nY)
print(int(max(XYnorm[2]+XYnorm[0],XYnorm[3]+XYnorm[1])))

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N=int(input())
XY = []
xAve = 0
yAve = 0
for _ in range(N):
    x,y=map(int,input().split())
    XY.append([x,y])
    xAve += x
    yAve += y
xAve = xAve//N
yAve = yAve//N
XYnorm = [0]*4
for x,y in XY:
    nX = x-xAve
    nY = y-yAve
    if nX>=0 and nY>0:#第1象限
        XYnorm[0]=max(XYnorm[0],nX+nY)
    if nX <0 and nY >=0:#第2象限
        XYnorm[1]=max(XYnorm[1],-nX+nY)
    if nX <=0 and nY <0:#第3象限
        XYnorm[2]=max(XYnorm[2],-nX-nY)
    if nX >0 and nY <=0:#第4象限
        XYnorm[3]=max(XYnorm[3],nX-nY)
print(max(XYnorm[2]+XYnorm[0],XYnorm[3]+XYnorm[1]))

Submission status: Wrong Answer

Solution code:
n = int(input())

mx_dis1, mn_dis1 = 0, 10**9
mx_dis2, mn_dis2 = 0, 10**9
for i in range(n):
    x, y = map(int, input().split())
    dis1 = x + y
    dis2 = x - y
    mx_dis1 = max(dis1, mx_dis1)
    mn_dis1 = min(dis1, mn_dis1)
    mx_dis2 = max(dis2, mx_dis2)
    mn_dis2 = min(dis2, mn_dis2)

ans1 = mx_dis1 - mn_dis1
ans2 = mx_dis2 - mn_dis2

print(max(ans1, ans2))

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N=int(input())
zmax=0
zmin = float('inf')
wmax = 0
wmin = float('inf')

for _ in range(N):
    x,y=map(int,input().split())
    z=x+y
    w=x-y
    zmax = max(z,zmax)
    zmin = min(z,zmin)
    wmax = max(w,wmax)
    wmin = min(w,wmin)
print(max(zmax-zmin,wmax-wmin))

Submission status: Wrong Answer

Solution code:
n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]
a = []
b = []
for i in range(n):
    a.append(abs(xy[i][0]+xy[i][1]))
    b.append(abs(xy[i][0]-xy[i][1]))
a_sort = sorted(a)
b_sort = sorted(b)

print(max(a_sort[-1]-a_sort[0],b_sort[-1]-b_sort[0]))

Submission status: Wrong Answer

Solution code:
N=int(input())
arr=[]
for i in range(N):
    x,y=map(int,input().split())
    arr.append([x,y])
arr1=arr.copy()
arr1.sort()
arr2=arr.copy()
arr2.sort(key=lambda x:x[1])
print(max((abs(arr1[0][0]-arr1[-1][0])+abs(arr1[0][1]-arr1[-1][1])),abs(arr2[0][0]-arr2[-1][0])+abs(arr2[0][1]-arr2[-1][1])))

Submission status: Wrong Answer

Solution code:
N=int(input())
xy = [tuple(map(int,input().split())) for _ in range(N)]
ans = 0

def dist(tpl1, tpl2):
    return abs(tpl1[0] - tpl2[0]) + abs(tpl1[1] - tpl2[1])

xy.sort()
min_x = xy[0][0]
max_x = xy[-1][0]
min_xx = []
max_xx = []
for i in range(N):
    if xy[i][0] == min_x:
        min_xx.append(xy[i])
    if xy[i][0] == max_x:
        max_xx.append(xy[i])
min_xx.sort(key=lambda x: x[1])
max_xx.sort(key=lambda x: x[1])
ans = max(ans, dist(min_xx[0], max_xx[-1]), dist(min_xx[-1], max_xx[0]))


xy.sort(key=lambda x: x[1])
min_y = xy[0][1]
max_y = xy[-1][1]
min_yy = []
max_yy = []
for i in range(N):
    if xy[i][1] == min_y:
        min_yy.append(xy[i])
    if xy[i][1] == max_y:
        max_yy.append(xy[i])
min_yy.sort()
max_yy.sort()
ans = max(ans, dist(min_yy[0], max_yy[-1]), dist(min_yy[-1], max_yy[0]))

print(ans)

Submission status: Wrong Answer

Solution code:
l = []
for _ in range(int(input())):
    x, y = map(int, input().split())
    l.append(x+y)
l.sort()
print(l[-1]-l[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(x) for x in input().split()])

xlim = []
ylim = []

def cha(a):
    return [a[0]-a[1],a[0]+a[1]]

for i in range(N):
    if cha(l[i])[0] <= cha(l[i])[1]:
        ylim.append(cha(l[i])[1])
    else:
        xlim.append(cha(l[i])[0])

xlim.sort()
ylim.sort()

if len(xlim)*len(ylim) != 0:
    print(max(-xlim[0]+xlim[-1],-ylim[0]+ylim[-1]))
elif len(xlim) == 0:
    print(-ylim[0]+ylim[-1])
elif len(ylim) == 0:
    print(-xlim[0]+xlim[-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
X = []
Y = []
for i in range(n):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)


now = 0
ind = -1
nx,ny = X[0],Y[0]
for i in range(1,n):
    x,y = X[i],Y[i]
    if now < abs(nx-x)+abs(ny-y):
        now = abs(nx-x)+abs(ny-y)
        ind = i
nx,ny = X[ind],Y[ind]
for i in range(n):
    x,y = X[i],Y[i]
    if now < abs(nx-x)+abs(ny-y):
        now = abs(nx-x)+abs(ny-y)


now2 = 0
ind = -1
nx,ny = X[1],Y[1]
for i in range(n):
    x,y = X[i],Y[i]
    if now2 < abs(nx-x)+abs(ny-y):
        now2 = abs(nx-x)+abs(ny-y)
        ind = i
nx,ny = X[ind],Y[ind]
for i in range(n):
    x,y = X[i],Y[i]
    if now2 < abs(nx-x)+abs(ny-y):
        now2 = abs(nx-x)+abs(ny-y)
print(max(now,now2))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(x) for x in input().split()])

xlim = []
ylim = []

def cha(a):
    return [a[0]-a[1],a[0]+a[1]]

for i in range(N):
    if cha(l[i])[0] >= cha(l[i])[1]:
        xlim.append(cha(l[i])[0])
    else:
        ylim.append(cha(l[i])[1])

xlim.sort()
ylim.sort()

if len(xlim)*len(ylim) != 0:
    print(max(-xlim[0]+xlim[-1],-ylim[0]+ylim[-1]))
elif len(xlim) == 0:
    print(-ylim[0]+ylim[-1])
elif len(ylim) == 0:
    print(-xlim[0]+xlim[-1])

Submission status: Wrong Answer

Solution code:
num_inputs = int(input())
pairs = []
for i in range(0, num_inputs):
  pair = input().split(" ")
  curr_x = int(pair[0])
  curr_y = int(pair[1])
  pairs.append(curr_x + curr_y)

print(max(pairs) - min(pairs))

Submission status: Wrong Answer

Solution code:
pnt=[]
n=int(input())
for i in range(n):
  pnt.append(list(map(int,input().split())))

z=[]
w=[]

for i in pnt:
  z.append(i[0]+i[1])
  w.append(i[0]+i[1])
print(max(max(z)-min(z),max(w)-min(w)))

Submission status: Wrong Answer

Solution code:
num_inputs = int(input())
max_pair = 0
for i in range(0, num_inputs):
  pair = input().split(" ")
  curr_x = int(pair[0])
  curr_y = int(pair[1])
  if i == 0:
    min_pair = curr_x + curr_y
  if (curr_x + curr_y) >= max_pair:
    max_pair = curr_x + curr_y
  elif (curr_x + curr_y) <= min_pair:
    min_pair = (curr_x + curr_y)
  print(min_pair, max_pair)
print(max_pair-min_pair)

Submission status: Wrong Answer

Solution code:
num_inputs = int(input())
max_pair = 0
for i in range(0, num_inputs):
  pair = input().split(" ")
  curr_x = int(pair[0])
  curr_y = int(pair[1])
  if i == 0:
    min_pair = curr_x + curr_y
  elif (curr_x + curr_y) > max_pair:
    max_pair = curr_x + curr_y
  elif (curr_x + curr_y) < min_pair:
    min_pair = (curr_x + curr_y)
print(max_pair-min_pair)