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())
table = [[int(i) for i in input().split()] for N in range(N)]

a = 0
b = 10**9 * 2
c = 0
d = 10**9 * 2
for i in range(N):
    p = table[i][0]
    q = table[i][1]
    if a < p+q:
        a = p+q
    if b > p+q:
        b = p+q
    if c < p-q:
        c = p-q
    if d > p-q:
        d = p-q

print(max(a-b,c-d))

Submission status: Wrong Answer

Solution code:
n = int(input())
n_list = []
dist_max = 0
total_xy_max = 0
total_xy_min = 0

for i in range(n):
    x, y = map(int, input().split())
    total_xy = x + y
    if n == 0:
        n_list.append([x, y])
        continue
    for j in range(len(n_list)):
        dist = abs(n_list[j][0] - x) + abs(n_list[j][1] - y)
        if dist > dist_max:
            dist_max = dist
    if total_xy < total_xy_min:
        total_xy_min = total_xy
        n_list.append([x, y])
    elif total_xy > total_xy_max:
        total_xy_max = total_xy
        n_list.append([x, y])
    elif (total_xy == total_xy_max or total_xy == total_xy_min) and ([x, y] in n_list == False):
        n_list.append([x, y])
    else:
        continue

print(dist_max)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
for i in range(n):
    x = list(map(int, input().split()))
    s.append(x)
t = sorted(s)
u = sorted(s, key=lambda x: x[1])
res = 0

for X in [t[0], u[0], t[-1], u[-1], t[n // 2], u[n // 2], t[-1 + n // 2], u[-1 + n // 2]]:
    for Y in [t[0], u[0], t[-1], u[-1], t[n // 2], u[n // 2], t[-1 + n // 2], u[-1 + n // 2]]:
        tmp = abs(X[0] - Y[0]) + abs(X[1] - Y[1])
        res = max(res, tmp)
print(res)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def main():
    n = int(input())
    xy = [list(map(int, input().split())) for i in range(n)]
    max_z, max_w, min_z, min_w = 0, 0, 10**20, 10**20
    ans = 0
    for p in xy:
        max_z, max_w = max(max_z, p[0] + p[1]), max(max_w, p[0] - p[1])
        min_z, min_w = min(min_z, p[0] + p[1]), min(min_w, p[0] - p[1])
    ans = max(max_z - min_z, max_w - min_w)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def main():
    n = int(input())
    xy = [list(map(int, input().split())) for i in range(n)]
    max_z, max_w, min_z, min_w = 0, 0, 10**10, 10**10
    ans = 0
    for p in xy:
        max_z, max_w = max(max_z, p[0] + p[1]), max(max_w, p[0] - p[1])
        min_z, min_w = min(min_z, p[0] + p[1]), min(min_w, p[0] - p[1])
    ans = max(max_z - min_z, max_w - min_w)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

a = 0
b = 10**9 * 2
c = 0
d = 10**9 * 2
for i in range(N):
    p = table[i][0]
    q = table[i][1]
    if a < p+q:
        a = p+q
    if b > p+q:
        b = p+q
    if c < abs(p-q):
        c = abs(p-q)
    if d > abs(p-q):
        d = abs(p-q)

print(max(a-b,c-d))

Submission status: Wrong Answer

Solution code:
mod=10**9+7
N=int(input())
print((10**N-(2*9**N)+(8**N))%mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
B = []
for i in range(N):
    x,y=[int(i) for i in input().split()]
    A.append(x)
    B.append(y)

mm = (10**9)*2
mmn = 0

pm = 10**9
pmn = 0

mp = 0
mpn = 0

pp = 0
ppn = 0

for j in range (N):
    if (A[j]+B[j])>pp:

        pp = A[j]+B[j]
        ppn = j
    if (10**9 - A[j]+B[j])>pm:

        pm = 10**9 - A[j]+B[j]
        pmn = j
    if (10**9 - A[j]+B[j])<mp:

        mp = 10**9 - A[j]+B[j]
        mpn = j
    if (A[j]+B[j])<mm:

        mm = A[j]+B[j]
        mmn = j
ans1 = abs(A[ppn] - A[mmn]) + abs(B[ppn] - B[mmn])
ans2 = abs(A[pmn] - A[mpn]) + abs(B[mpn] - B[pmn])
ans3 = abs(A[ppn] - A[pmn]) + abs(B[ppn] - B[pmn])
ans4 = abs(A[mmn] - A[mpn]) + abs(B[mmn] - B[mpn])
ans5 = abs(A[ppn] - A[mpn]) + abs(B[ppn] - B[mpn])
ans6 = abs(A[mmn] - A[pmn]) + abs(B[mmn] - B[pmn])
ans = max(ans1,ans2,ans3,ans4,ans5,ans6)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
f0 = sorted([x+y for x, y in xy])
f1 = sorted([x-y for x, y in xy])
print(max(f0[-1]+f1[0], f0[0]+f1[-1]))

Submission status: Wrong Answer

Solution code:
n=int(input())
xy=[]
for i in range(n):
  tmp=list(map(int,input().split()))
  xy.append(tmp)
maxz,minz,maxw,minw=0,10**10,0,10**10
for i in range(n):
  maxz=max(maxz,xy[i][0]+xy[i][1])
  minz=min(minz,xy[i][0]+xy[i][1])
  maxw=max(maxw,xy[i][0]-xy[i][1])
  minw=min(minw,xy[i][0]-xy[i][1])
print(max(maxz-minz,maxw-minw))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7


N = int(input())
x = [None] * N
y = [None] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

xmax = x.index(max(x))
xmin = x.index(min(x))
ymax = y.index(max(y))
ymin = y.index(min(y))
ans = 0
for i in [xmin, ymin]:
    for j in [xmax, ymax]:
        ans = max(ans, abs(x[i]-x[j])+abs(y[i]-y[j]))

print(ans)

Submission status: Wrong Answer

Solution code:
n = int (input())

xy = []

def dist(a, b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])
    
for i in range(n):
    x, y = map(int,input().split())
    xy.append([x+y, x-y])

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

dist(xy[0], xy[-1])


ans = 0
l = int((n//2)**0.5)
for i in range(l):
    for j in range(l+1):
        ans = max(ans, dist(xy[i], xy[n-1-j]))

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
zmax=0
zmin=float("inf")
wmax=0
wmin=float("inf")

for i in range(n):
    a,b=map(int,input().split())
    zmax=max(zmax,a+b)
    zmin=min(zmin,a+b)
    wmax=max(wmax,a-b)
    wmin=min(wmin,a-b)
    
print(max(zmax-zmin,wmax-wmin))

Submission status: Wrong Answer

Solution code:
import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    x, y = i2(N)

    Mw = max(x[i]+y[i] for i in range(N))
    mw = min(x[i]+y[i] for i in range(N))
    Mz = max(abs(x[i]-y[i]) for i in range(N))
    mz = min(abs(x[i]-y[i]) for i in range(N))

    print(max(Mz-mz, Mw-mw))
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def get_output():
    dist = [0 for _ in range(N)]
    min_x, max_x = 0, 0
    min_y, max_y = 0, 0

    for i, (x, y) in enumerate(xy):
        x, y = (x-y), (x+y)

        min_x = min(x, min_x)
        min_y = min(y, min_y)
        max_x = max(x, max_x)
        max_y = max(y, max_y)

    return max(max_x - min_x, max_y - min_y)


print(get_output())

Submission status: Wrong Answer

Solution code:
N = int(input())
mant = [0 for _ in range(N)]
for i in range(N):
    x, y = map(int, input().split())
    mant[i] = x + y

print(max(mant)-min(mant))

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    mat = []
    a = []
    b = []

    for _ in range(N):
        x, y = map(int, readline().split())
        a.append(x + y)
        b.append(abs(x - y))

    d1 = max(a) - min(a)
    d2 = max(b) - min(b)

    print(max(d1,d2))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
L1 = []
L2 = []
L3 = []
L4 = []
for i in range(N):
    x, y = map(int, input().split())
    if x >= 0 and y >= 0:
        L1.append([x, y])
    elif x < 0 and y >= 0:
        L2.append([x, y])
    elif x < 0 and y < 0:
        L3.append([x, y])
    else:
        L4.append([x, y])
L1.sort(key = lambda x: abs(x[0] + x[1]), reverse = True)
L2.sort(key = lambda x: abs(x[0] + x[1]), reverse = True)
L3.sort(key = lambda x: abs(x[0] + x[1]), reverse = True)
L4.sort(key = lambda x: abs(x[0] + x[1]), reverse = True)

base = []
for L in [L1, L2, L3, L4]:
    if len(L) != 0:
        base.append(L[0])
        
ans = 0
for b in base:
    base_x = b[0]
    base_y = b[1]
    for l in L1 + L2 + L3 + L4:
        ans = max(ans, abs(l[0] - base_x) + abs(l[1] - base_y))

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())


min_m = 10**9 *2
min_h = 10**9


list_xy = []

min_m_i = 0
min_h_i = 0

for i in range(N):
    t = list(map(int, input().split()))
    list_xy.append(t)
    
    if min_m > 10**9 - t[0] + 10**9 - t[1]:
        
        min_m = 10**9 - t[0] + 10**9 - t[1]
        min_m_i = i

    
    if min_h > t[0] + t[1]:
        
        min_h = t[0] + t[1]
        min_h_i = i



mmm = list_xy[min_m_i]
hhh = list_xy[min_h_i]

print(abs(mmm[0] - hhh[0]) + abs(mmm[1] - hhh[1]))

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())

upper = []
lower = []
for _ in range(N):
    x, y = mapint()
    if x<=y:
        upper.append((x, y))
    else:
        lower.append((x, y))
upper.sort(key=lambda x:x[0]+x[1])
lower.sort(key=lambda x:x[0]+x[1])

if len(upper):
    upper_max = abs(upper[0][0]-upper[-1][0]) + abs(upper[0][1]-upper[-1][1])
else:
    upper_max = 0

if len(lower):
    lower_max = abs(lower[0][0]-lower[-1][0]) + abs(lower[0][1]-lower[-1][1])
else:
    lower_max = 0

if len(upper) and len(lower):
    upper.sort(key=lambda x:abs(x[0]-x[1]), reverse=True)
    lower.sort(key=lambda x:abs(x[0]-x[1]), reverse=True)
    upper_max = max(upper_max, abs(upper[0][0]-upper[-1][0]) + abs(upper[0][1]-upper[-1][1]))
    lower_max = max(lower_max, abs(lower[0][0]-lower[-1][0]) + abs(lower[0][1]-lower[-1][1]))
    upper_lower = abs(upper[0][0]-lower[0][0]) + abs(upper[0][1]-lower[0][1])
else:
    upper_lower = 0

print(max(upper_max, lower_max, upper_lower))

Submission status: Wrong Answer

Solution code:
N =int(input())

E = []
F = []

for i in range(N):
    x,y = map(int,input().split())
    E.append(x)
    F.append(y)

#print(E)
#print(F)

E1 = sorted(E)
F1 = sorted(F)

#print(E1)
#print(F1)

x = E1[-1] - E1[0]
y = F1[-1] - F1[0]

E1[0]

e0 = E.index(E1[0])
#print(E1[0],F[e0])
EE0 =[E1[0],F[e0]]
#print(EE0[0])


e1 = E.index(E1[-1])
#print(E1[-1],F[e1])
EE1 =[E1[-1],F[e1]]

#print((EE1[0] - EE0[0])+( EE1[-1] -EE0[-1]))
Ex1 =(EE1[0] - EE0[0])+( EE1[-1] -EE0[-1])

f0 = F.index(F1[0])
FF0 =[F1[0],E[f0]]

f1 = F.index(F1[-1])
FF1 =[F1[-1],E[f1]]

#print((FF1[0] - FF0[0])+( FF1[-1] -FF0[-1]))
Fx1= (FF1[0] - FF0[0])+( FF1[-1] -FF0[-1])

if Fx1 >= Ex1:
    print(Fx1)
else:
    print(Ex1)

Submission status: Wrong Answer

Solution code:
rt = 0
N = int(input())
nums=[]
for _ in range(N):
  nums.append(list(map(int,input().split())))
mn = nums[0][0] + nums[0][1]
mx = nums[0][0] + nums[0][1]
for i in nums:
  mn = min(mn,i[0]+i[1])
  mx = max(mx,i[0]+i[1])
print(mx-mn)

Submission status: Wrong Answer

Solution code:
N = int(input())
def f0(x,y):
    return x-y

def f1(x,y):
    return x+y



max0 = 0
max1 = 0
min0 = 10**10
min1 = 10**10

for i in range(N):
    x,y = map(int, input().split())

    a = f0(x,y)
    b = f1(x,y)

    max0 = max(a, max0)
    min0 = min(a, min0)
    max1 = max(b, max1)
    min1 = min(b, min1)



res = max(max0-min0, max1-min1)
if res < 0:
    res = 0
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
def f0(x,y):
    return x-y

def f1(x,y):
    return x+y



max0 = 0
max1 = 0
min0 = 10**10
min1 = 10**10

for i in range(N):
    x,y = map(int, input().split())

    a = f0(x,y)
    b = f1(x,y)

    max0 = max(a, max0)
    min0 = min(a, min0)
    max1 = max(b, max1)
    min1 = min(b, min1)


print(max(max0-min0, max1-min1))

Submission status: Wrong Answer

Solution code:
n = int(input())
maxsum = -float('inf')
minsum = float('inf')
maxdif = -float('inf')
mindif = float('inf')
for i in range(n):
  x, y = map(int, input().split())
  trysum = x + y
  trydif = x - y
  if trysum >= maxsum:
    maxsum = trysum
  if trysum <= minsum:
    minsum = trysum
  if trydif >= maxdif:
    maxdif = trydif
  if trydif <= minsum:
    mindif = trydif
print(max(maxsum - minsum, maxdif - mindif))

Submission status: Wrong Answer

Solution code:
N=int(input())
xy=[]
for i in range(N):
    x,y=map(int,input().split())
    xy.append([x,y,x**2+y**2])
xy=sorted(xy,key=lambda x:x[2])
print(abs(xy[0][0]-xy[-1][0])+abs(xy[0][1]-xy[-1][1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
def f0(x,y):
    return x-y

def f1(x,y):
    return x+y



max0 = 0
max1 = 0
min0 = 10000000
min1 = 10000000

for i in range(N):
    x,y = map(int, input().split())

    a = f0(x,y)
    b = f1(x,y)

    max0 = max(a, max0)
    min0 = min(a, min0)
    max1 = max(b, max1)
    min1 = min(b, min1)


print(max(max0-min0, max1-min1))

Submission status: Wrong Answer

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

min_diff = 10**9
max_diff = 0
min_sum = 2 * 10**9
max_sum = 2

for x,y in XY:
    min_diff = min(abs(x-y), min_diff)
    max_diff = max(abs(x-y), max_diff)
    min_sum = min(x+y, min_sum)
    max_sum = max(x+y, max_sum)

print(max(max_sum-min_sum, max_diff-min_diff))

Submission status: Wrong Answer

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N = I()
A,B = [],[]  # x+y,x-y たちのリスト
for i in range(N):
    x,y = MI()
    A.append(x+y)
    B.append(x-y)

print(max(A)-min(A),max(B)-min(B))

Submission status: Wrong Answer

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

tmp1 = []
tmp2 = []
for i in range(n):
    tmp1.append([xy[i][0]+xy[i][1], xy[i][0], xy[i][1]])
    tmp2.append([xy[i][0]-xy[i][1], xy[i][0], xy[i][1]])
tmp1.sort()
tmp2.sort()

if n <= 1000:
    ii = n
    jj = n+1
else:
    ii = 1000
    jj = 1000

ans = 0
for i in range(ii):
    for j in range(1, jj):
        if (tmp1[-j][2]-tmp1[i][2]) >= (tmp1[-j][1]-tmp1[i][1]):
            tmp = tmp1[-j][0]-tmp1[i][0]
            ans = max(tmp, ans)
        if (tmp2[-j][2]-tmp2[i][2]) <= (tmp2[-j][1]-tmp2[i][1]):
            tmp = tmp2[-j][0]-tmp2[i][0]
            ans = max(tmp, ans)

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
answer=0

xylist=[]
pxylist=[]
mxylist=[]
for _ in range(N):
  x,y=map(int,input().split())
  xylist.append((x,y))
  pxylist.append(x+y)
  mxylist.append(x-y)
pxylist.sort()
mxylist.sort()

answer=max(pxylist[-1]-pxylist[0],mxylist[-1],mxylist[0])
print(answer)

Submission status: Wrong Answer

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

min_diff = 10**9
max_diff = 1
min_sum = 2 * 10**9
max_sum = 2

for x,y in XY:
    min_diff = min(abs(x-y), min_diff)
    max_diff = max(abs(x-y), max_diff)
    min_sum = min(x+y, min_sum)
    max_sum = max(x+y, max_sum)

print(max(max_sum-min_sum, max_diff-min_diff))

Submission status: Wrong Answer

Solution code:
n = int(input())

edge0 = list(map(lambda x: int(x), input().split()))
edge1 = list(map(lambda x: int(x), input().split()))
dis = abs(edge0[0]-edge1[0]) + abs(edge0[1]-edge1[1])

for _ in range(n-2):
    x, y = map(lambda x: int(x), input().split())
    if (x < min(edge0[0], edge1[0])) | (max(edge0[0], edge1[0]) < x) | (y < min(edge0[1], edge1[1])) | (max(edge0[1], edge1[1]) < y):
        dis_from_edge0 = abs(x-edge0[0]) + abs(y-edge0[1])
        dis_from_edge1 = abs(x-edge1[0]) + abs(y-edge1[1])

#       print(dis_from_edge0, dis_from_edge1)
        # 更新なし
        if max(dis_from_edge0, dis_from_edge1) <= dis:
#           print('#1', edge0, edge1, dis)
            continue
        # どちらも更新
        if min(dis_from_edge0, dis_from_edge1) > dis:
            if dis_from_edge0 < dis_from_edge1:
                dis = dis_from_edge1
                edge0 = [x, y]
            else:
                dis = dis_from_edge0
                edge1 = [x, y]
#                 print('#2', edge0, edge1, dis)
            continue
        if dis_from_edge0 > dis:
            dis = dis_from_edge0
            edge1 = [x, y]
#           print('#3', edge0, edge1, dis)
            continue
        if dis_from_edge1 > dis:
            dis = dis_from_edge1
            edge0 = [x, y]
            continue
print(dis)

    #     x_max = max(x, x_max)
    #     x_min = min(x, x_min)
    #     y_max = max(y, y_max)
    #     y_min = min(y, y_min)

Submission status: Wrong Answer

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

min_diff = 10**9
max_diff = 1
min_sum = 2 * 10**9
max_sum = 2

for x,y in XY:
    min_diff = min(x-y, min_diff)
    max_diff = max(x-y, max_diff)
    min_sum = min(x+y, min_sum)
    max_sum = max(x+y, max_sum)

print(max(max_sum-min_sum, max_diff-min_diff))

Submission status: Wrong Answer

Solution code:
N=int(input())
listx=[]
listy=[]
for i in range(N):
  x,y=map(int,input().split())
  listx.append(x)
  listy.append(y)
maxx=[0,0,0]
maxx[1]=listx.index(max(listx))
maxx[2]=listx.index(min(listx))
maxx[0]=listx[maxx[1]]-listx[maxx[2]]
maxy=[0,0,0]
maxy[1]=listy.index(max(listy))
maxy[2]=listy.index(min(listy))
maxy[0]=listy[maxy[1]]-listx[maxy[2]]

if maxx[0]+abs(listy[maxx[1]]-listy[maxx[2]])>maxy[0]+abs(listx[maxy[1]]-listx[maxy[2]]):
  print(maxx[0]+abs(listy[maxx[1]]-listy[maxx[2]]))
else:
  print(maxy[0]+abs(listx[maxy[1]]-listx[maxy[2]]))

Submission status: Wrong Answer

Solution code:
N = int(input())
K = []
for i in range(N):
    x, y = map(int,input().split())
    t = x + y
    if x <= 0:
        t -= 4*abs(x)
    if y <= 0:
        t -= 4*abs(y)
    K.append([t, x, y])

K.sort()
A = [K[0][0]]
ans = K[-1][0] - K[0][0]
for i in range(N-1):
    if K[i][0] == K[i+1][0]:
        A.append(K[i+1][1])
    else:
        ans = max(ans, max(A) - min(A))
        A = [K[i][1]]
print(ans)

Submission status: Wrong Answer

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

tmp1 = []
tmp2 = []
for i in range(n):
    tmp1.append([xy[i][0]+xy[i][1], xy[i][0], xy[i][1]])
    tmp2.append([xy[i][0]-xy[i][1], xy[i][0], xy[i][1]])
tmp1.sort()
tmp2.sort()

if n <= 100:
    ii = n
    jj = n+1
else:
    ii = 100
    jj = 100

ans = 0
for i in range(ii):
    for j in range(1, jj):
        if (tmp1[-j][2]-tmp1[i][2]) >= (tmp1[-j][1]-tmp1[i][1]):
            tmp = tmp1[-j][0]-tmp1[i][0]
            ans = max(tmp, ans)
        if (tmp2[-j][2]-tmp2[i][2]) <= (tmp2[-j][1]-tmp2[i][1]):
            tmp = tmp2[-j][0]-tmp2[i][0]
            ans = max(tmp, ans)

print(ans)

Submission status: Wrong Answer

Solution code:

n = int(input().strip())
l = []

for i in range(n):
    x, y = map(int, input().split())
    a = y + x
    b = y - x
    l.append([x, y, a, b])

la = sorted(l, key=lambda z: z[2])
lb = sorted(l, key=lambda z: z[3])

print(max(abs(la[0][0] - la[-1][0]) + abs(la[0][1]-la[-1][1]),
          abs(lb[0][0] - lb[-1][0]) + abs(la[0][1]-la[-1][1])
          )
      )

Submission status: Wrong Answer

Solution code:
n = int(input())
n_list = []
dist_max = 0
total_xy_max = 0
total_xy_min = 0

for i in range(n):
    x, y = map(int, input().split())
    total_xy = x + y
    if n == 0:
        n_list.append([x, y])
        continue
    for j in range(len(n_list)):
        dist = abs(n_list[j][0] - x) + abs(n_list[j][1] - y)
        if dist > dist_max:
            dist_max = dist
    if total_xy <= total_xy_min:
        total_xy_min = total_xy
        n_list.append([x, y])
    elif total_xy >= total_xy_max:
        total_xy_max = total_xy
        n_list.append([x, y])
    else:
        continue

print(dist_max)

Submission status: Wrong Answer

Solution code:
n = int(input())
r = [0,0]
t = [0,0]
l = [10**9+1,10**9+1]
bot = [10**9+1,10**9+1]
for _ in range(n):
    a, b = map(int, input().split())
    if a >= r[0]:
        if a > r[0] or b > r[1]:
            r = [a, b]
    if a <= l[0]:
        if a < l[0] or b < r[1]:
            l = [a, b]
    if b >= t[1]:
        if b > t[1] or a > t[0]:
            t = [a, b] 
    if b <= bot[1]:
        if b < bot[1] or a < bot[0]:
            bot = [a, b]

def manhat(A, B):
    return abs(A[0]-B[0])+abs(A[1]-B[1])

res = max(manhat(l,r), manhat(bot,r), manhat(l,t), manhat(bot,t), manhat(t,r), manhat(l,bot))
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
max_t = -float('inf')
min_t = float('inf')
dic_p_x = {}
for _ in range(n):
  x, y = map(int, input().split())
  c = x + y
  if c > max_t:
    max_t = c
  if c < min_t:
    min_t = c
  if c not in dic_p_x:
    dic_p_x[c] = []
  dic_p_x[c].append(x)
max_d = max_t - min_t
for lst in dic_p_x.values():
  a, b = max(lst), min(lst)
  dis = 2 * (a - b)
  max_d = max(max_d, dis)
print(max_d)

Submission status: Wrong Answer

Solution code:
class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.upper_left = False
        self.upper_right = False
        self.lower_left = False
        self.lower_right = False


def main():
    n = int(input())
    points = set()
    for _ in range(n):
        x, y = map(int, input().split())
        add_point = Point(x, y)

        next_points = set()
        for point in points:
            upper_flag = point.y < add_point.y
            left_flag = point.x < add_point.x

            if upper_flag and left_flag:
                point.upper_left = True
                add_point.lower_right = True

            if upper_flag and not left_flag:
                point.upper_right = True
                add_point.lower_left = True

            if not upper_flag and left_flag:
                point.lower_left = True
                add_point.upper_right = True

            if not upper_flag and not left_flag:
                point.lower_right = True
                add_point.upper_left = True

            if not (point.upper_left and point.lower_right) and\
                    not (point.upper_right and point.lower_left):
                next_points.add(point)

        if not (add_point.upper_left and add_point.lower_right) and \
                not (add_point.upper_right and add_point.lower_left):
            next_points.add(add_point)

        points = next_points

    max_dist = 0
    for point1 in points:
        for point2 in points:
            max_dist = max(max_dist, abs(point1.x - point2.x) + abs(point1.y - point2.y))

    print(max_dist)


main()

Submission status: Wrong Answer

Solution code:
import math
#N = map(int,input().split())
#AB=[]
N = int(input())
#C = input()
#D, T, S=map(int,input().split())
C = []
D = []
for i in range(N):
    al = list(map(int,input().split()))
    if al not in C:
        C.append(al)
        D.append([al[0]-al[1],al[0]+al[1]])
min0 = 1000000000
max0 = 0
min1 = 1000000000
max1 = 0
for i in D:
    p = i[0]
    q = i[1]
    if max0 <= p:
        max0 = p
    if min0 >= p:
        min0 = p
    if max1 <= q:
        max1 = q
    if min1 >= q:
        min1 = q

print(max(max0-min0, max1-min1))

Submission status: Wrong Answer

Solution code:
n = int(input())
n_list = []
dist_max = 0
total_xy_max = 0
total_xy_min = 0

for i in range(n):
    x, y = map(int, input().split())
    total_xy = x + y
    if n == 0:
        n_list.append([x, y])
        continue
    for j in range(len(n_list)):
        dist = abs(n_list[j][0] - x) + abs(n_list[j][1] - y)
        if dist > dist_max:
            dist_max = dist
    if total_xy < total_xy_min:
        total_xy_min = total_xy
        n_list.append([x, y])
    elif total_xy > total_xy_max:
        total_xy_max = total_xy
        n_list.append([x, y])
    else:
        continue

print(dist_max)

Submission status: Wrong Answer

Solution code:
from copy import copy

N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]
for i in range(N):
    x, y = copy(XY[i][0]), copy(XY[i][1])
    XY[i][0] = x-y
    XY[i][1] = x+y

ans = 0
for i in range(2):
    tmp_1 = 0
    tmp_2 = float("inf")
    for j in range(N):
        tmp_1 = max(tmp_1, XY[j][i])
        tmp_2 = min(tmp_2, XY[j][i])
    ans = max(ans, tmp_1-tmp_2)
print(ans)

Submission status: Wrong Answer

Solution code:

N = int(input())
xs = []
ys = []

for _ in range(N):
    x, y = list(map(int, input().split(" ")))
    xs.append(x)
    ys.append(y)

max_dist = 0

for i in range(N):
    for j in range(i + 1, N):
        dist = abs(xs[i] - xs[j]) + abs(ys[i] - ys[j])
    if dist > max_dist:
        max_dist = dist

print(max_dist)

Submission status: Wrong Answer

Solution code:
N = int(input())
x, y = map(int,input().split())
min_ = [(x,y)]
max_ = [(x,y)]
L = x ** 2 + y ** 2
min_L = L
max_L = L

cont = 10**9
min_2 = [(x,y)]
max_2 = [(x,y)]
L2 = x ** 2 + (cont - y) ** 2
min_L2 = L2
max_L2 = L2

for i in range(N-1):
  x, y = map(int, input().split())
  L = x ** 2 + y ** 2
  if min_L > L:
    min_ = [(x,y)]
    min_L = L
  if min_L == L:
    min_.append((x,y))
  if max_L < L:
    max_ = [(x,y)]
    max_L = L
  if max_L == L:
    max_.append((x,y))
    
  L2 = x ** 2 + (cont - y) ** 2
  if min_L2 > L2:
    min_2 = [(x,y)]
    min_L2 = L2
  if min_L2 == L2:
    min_2.append((x,y))
  if max_L2 < L2:
    max_2 = [(x,y)]
    max_L2 = L2
  if max_L2 == L2:
    max_2.append((x,y))
max1 = 0
for (max_x,max_y) in max_:
  for (min_x,min_y) in min_:
    l = max_x - min_x + max_y - min_y
    if max1 < l:
      max1 = l
max2 = 0
for (max_x,max_y) in max_2:
  for (min_x,min_y) in min_2:
    l = max_x - min_x + min_y - max_y
    if max2 < l:
      max2 = l
print(max(max1,max2))

Submission status: Wrong Answer

Solution code:
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

n = ii()
l = []
for i in range(n):
    l += [li()]

p, q, r, s = [0,0,1000000000,1000000000]
for x in l:
    p = max(p, x[0] + x[1])
    q = max(q, x[0] - x[1])
    r = min(r, x[0] + x[1])
    s = min(s, x[0] - x[1])

print(max(p-r, q-s))

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
X=[]
for i in range(N):
  array = list(map(int,input().split()))
  X.append(array)


a = np.array(X).T

xmax=[]
xmin=[]
xmax=np.argmax(a,axis=1)
xmin=np.argmin(a,axis=1)


x1=X[xmax[0]]
y1=X[xmax[1]]
x0=X[xmin[0]]
y0=X[xmin[1]]


x=abs(x1[0]-x0[0])+abs(x1[1]-x0[1])
y=abs(y1[0]-y0[0])+abs(y1[1]-y0[1])

print(max(x,y))

Submission status: Wrong Answer

Solution code:

N = int(input())

l = [None] * N

for i in range(N):
    l[i] = list(map(int, input().split()))

minX = min([e[0] for e in l])
minY = min([e[1] for e in l])
maxX = max([e[0] for e in l])
maxY = max([e[1] for e in l])

p = [None] * 8
p[0] = [minX, min([e[1] for e in l if e[0] == minX])]
p[1] = [minX, max([e[1] for e in l if e[0] == minX])]

p[2] = [min([e[0] for e in l if e[1] == minY]), minY]
p[3] = [max([e[0] for e in l if e[1] == minY]), minY]

p[4] = [maxX, min([e[1] for e in l if e[0] == maxX])]
p[5] = [maxX, max([e[1] for e in l if e[0] == maxX])]

p[6] = [min([e[0] for e in l if e[1] == maxY]), maxY]
p[7] = [max([e[0] for e in l if e[1] == maxY]), maxY]

def d(_a, _b):
    return abs(_a[0]-_b[0])+abs(_a[1]-_b[1])

s0 = min([d([minX,minY], e) for e in l])
s1 = min([d([maxX,maxY], e) for e in l])
 
t0 = min([d([maxX,minY], e) for e in l])
t1 = min([d([maxX,minY], e) for e in l])
 

print(max(d([minX,minY], [maxX,maxY]) - min(s0+s1, t0+t1),
max([d(p0,p1) for p0 in p for p1 in p])))

Submission status: Wrong Answer

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

min_x = math.inf 
min_y = math.inf 
max_x = -math.inf 
max_y = -math.inf

max_dis = 0

pairs = []
def dist(a, b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])

for i in range(N):
    x, y = map(int, input().split())
    if min_x > x:
        for p in pairs:
            d = dist(p, (x,y))
            if d > max_dis:
                max_dis= d
        min_x = x
    if min_y > y:
        for p in pairs:
            d = dist(p, (x,y))
            if d > max_dis:
                max_dis= d
        min_y = y
    if max_x < x:
        for p in pairs:
            d = dist(p, (x,y))
            if d> max_dis:
                max_dis= d
        max_x = x
    if max_y < y:
        for p in pairs:
            d = dist(p, (x,y))
            if d > max_dis:
                max_dis= d
        max_y = y
    pairs.append((x,y))
print(max_dis)

Submission status: Wrong Answer

Solution code:
n = int(input())
c = [[int(i) for i in input().split()] for i in range(n)]
x_0 = c[0][0]
y_0 = c[0][1]
x_1 = c[1][0]
y_1 = c[1][1]
l = abs(x_0 - x_1) + abs(y_0 - y_1)
for i in range(1,n):
    x = c[i][0]
    y = c[i][1]
    l0 = abs(x_0 - x) + abs(y_0 - y)
    l1 = abs(x_0 - x) + abs(y_0 - y)
    if l < max(l0, l1):
        l = max(l0,l1)
        if l0 < l1:
            x_0 = x
            y_0 = y
        else:
            x_1 = x
            y_1 = y
print(l)

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)
  Y.append(x-y)
max_x=max(X)
min_x=min(X)
max_y=max(Y)
min_y=min(Y)
l=max(max_x-min_x,max_y-min_y)
P=[(min(X)+l//2,min(Y)+l//2),(min(X)+l//2,max(Y)-l//2),
  (max(X)-l//2,min(Y)+l//2),(max(X)-l//2,max(Y)-l//2)]
ans=0
print((max_x-min_y)//2)

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
X=[]
for i in range(N):
  array = list(map(int,input().split()))
  X.append(array)


a = np.array(X).T

xmax=[]
xmin=[]
xmax=np.argmax(a,axis=1)
xmin=np.argmin(a,axis=1)


x1=X[xmax[0]]
y1=X[xmax[1]]
x0=X[xmin[0]]
y0=X[xmin[1]]
print(x1)

x=abs(x1[0]-x0[0])+abs(x1[1]-x0[1])
y=abs(y1[0]-y0[0])+abs(y1[1]-y0[1])

print(max(x,y))