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:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    points = []
    for _ in range(n):
        x, y = map(int, input().split())
        points.append((2*x, 2*y))

    points.sort(key=lambda p: p[0] + (p[1]-p[0])//2)
    x1, y1 = points[0]
    x2, y2 = points[-1]
    print((abs(x2-x1) + abs(y2-y1))//2)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!python3

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

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

    M = 10**9+1
    data = [[M, 0], [M, 0]]
    for x, y in zip(it, it):
        for i, x in enumerate([x+y, x-y]):
            for j, f in enumerate([min, max]):
                data[i][j] = f(data[i][j], x)

    print(max(map(lambda x: abs(sub(*x)), data)))



if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
N = int(input())

x_plus_y = set()
x_minus_y = set()

for _ in range(N):
    x, y = map(int, input().split())
    x_plus_y.add(x+y)
    x_minus_y.add(x+y)

print(max([abs(max(x_plus_y)-min(x_plus_y)), abs(max(x_minus_y)-min(x_minus_y))]))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n = int(input())
a=0
b=float('inf')
c=0
d=float('inf')
for i in range(n):
    x, y = map(int,input().split())
    a=max(a, x+y)
    b=min(b, x+y)
    c=max(c, x-y)
    d=min(d, x-y)
print(max(abs(a-b),abs(c-d)))

Submission status: Wrong Answer

Solution code:
N = int(input())

x, y = [0]*N, [0]*N

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

maxZ, minZ, maxW, minW = -1, float("inf"), -1, float("inf")
for i in range(N):
    z = x[i] + y[i]
    w = x[i] - y[i]

    maxZ = max(maxZ, z)
    minZ = min(minZ, z)
    maxW = max(maxW, w)
    minW = min(minW, w)

ans = max(maxZ-minZ, maxW-minW)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l.sort()

ans = abs(l[0][2]-l[-1][2])+abs(l[0][1]-l[-1][1])
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

inf = float('inf')

M1, M2 = 0, 0
m1, m2 = inf, inf

for i in range(n):
  x, y = map(int, input().split())
  d1 = x+y
  d2 = x-y
  M1 = max(M1, d1)
  m1 = min(m1, d1)
  M2 = max(M2, d2)
  m2 = min(m2, d2)

D1 = M1-m1
D2 = M2-m2

print(max(D1, D2))

Submission status: Wrong Answer

Solution code:
n = int(input())

M1, M2 = 0, 0
m1 = m2 = float('inf')

for i in range(n):
  x, y = map(int, input().split())
  d1 = x+y
  d2 = x-y
  M1 = max(M1, d1)
  m1 = min(m1, d1)
  M2 = max(M2, d2)
  m2 = min(m2, d2)

d1 = M1-m1
d2 = M2-m2

print(max(d1, d2))

Submission status: Wrong Answer

Solution code:
n = int(input())

lst1 = [0]*n
lst2 = [0]*n

M1 = M2 = 0
m1 = m2 = float('inf')

for i in range(n):
  x, y = map(int, input().split())
  d1 = x+y
  d2 = x-y
  M1 = max(M1, d1)
  m1 = min(m1, d1)
  M2 = max(M2, d2)
  m2 = min(m2, d2)

d1 = M1-m1
d2 = M2-m2

print(max(d1, d2))

Submission status: Wrong Answer

Solution code:
def seekDistance(n,nodes):
    max_z,min_z = searchMaxAndMinZ(n,nodes)
    max_w,min_w = searchMaxAndMinW(n,nodes)
    return max(max_z-min_z,max_w-min_w)

def searchMaxAndMinZ(n,nodes):
    max_z = -1
    min_z = 2 * 10 ** 9
    for i in range(n):
        curr_z = nodes[i][0] + nodes[i][1]
        if(curr_z > max_z):
            max_z = curr_z
        if(curr_z < min_z):
            min_z = curr_z
    return max_z,min_z

def searchMaxAndMinW(n,nodes):
    max_w = -1
    min_w = 2 * 10 ** 9
    for i in range(n):
        curr_w = nodes[i][0] - nodes[i][1]
        if (curr_w > max_w):
            max_w = curr_w
        if (curr_w < min_w):
            min_w = curr_w
    return max_w, min_w

n = int(input())
nodes = [list(map(int,input().split())) for i in range(n)]
print(seekDistance(n,nodes))

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
V = set()
for s in sys.stdin.readlines():
    x, y = map(int, s.split())
    V.add((x, y))

INF = float('inf')
v1 = (0, -INF)
v2 = (-INF, 0)
v3 = (0, INF)
v4 = (INF, 0)

for x, y in V:
    if y > v1[1]:
        v1 = (x, y)
    if x > v2[0]:
        v2 = (x, y)
    if y < v3[1]:
        v3 = (x, y)
    if x < v4[0]:
        v4 = (x, y)

ans = 0
V = [v1, v2, v3, v4]
for i in range(4):
    x1, y1 = V[i]
    for j in range(i + 1, 4):
        x2, y2 = V[j]
        l = abs(x1 - x2) + abs(y1 - y2)
        ans = max(ans, l)

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:tuple(map(int,stdin.readline().split()))

n=int(input())

l=set(tuple([lnii() for i in range(n)]))

x_max=0
x_min=10**10
y_max=0
y_min=10**10

for x,y in l:
#  s=abs(x-y)
  s=x-y
  x_max=max(x_max,s)
  x_min=min(x_min,s)

#  t=abs(x+y)
  t=x+y
  y_max=max(y_max,t)
  y_min=min(y_min,t)

x_ans=x_max-x_min
y_ans=y_max-y_min
print(max(x_ans,y_ans))

Submission status: Wrong Answer

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:tuple(map(int,stdin.readline().split()))

n=int(input())
l=set(tuple([lnii() for i in range(n)]))

x_max=0
x_min=10**10
y_max=0
y_min=10**10

for x,y in l:
  s=x-y
  x_max=max(x_max,s)
  x_min=min(x_min,s)

  t=x+y
  y_max=max(y_max,t)
  y_min=min(y_min,t)

x_ans=x_max-x_min
y_ans=y_max-y_min
print(max(x_ans,y_ans))

Submission status: Wrong Answer

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:tuple(map(int,stdin.readline().split()))

n=int(input())

l=tuple([lnii() for i in range(n)])

if len(l)==1:
  print(0)
  exit()

x_max=0
x_min=10**10
y_max=0
y_min=10**10

for x,y in l:
  s=x-y
  x_max=max(x_max,s)
  x_min=min(x_min,s)

  t=x+y
  y_max=max(y_max,t)
  y_min=min(y_min,t)

x_ans=x_max-x_min
y_ans=y_max-y_min
print(max(x_ans,y_ans))

Submission status: Wrong Answer

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())

l=[lnii() for i in range(n)]

if len(l)==1:
  print(0)
  exit()

x_max=0
x_min=10**10
y_max=0
y_min=10**10

for x,y in l:
  s=x-y
  x_max=max(x_max,s)
  x_min=min(x_min,s)

  t=x+y
  y_max=max(y_max,t)
  y_min=min(y_min,t)

x_ans=x_max-x_min
y_ans=y_max-y_min
print(max(x_ans,y_ans))

Submission status: Wrong Answer

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())

z_max=0
z_min=10**10
w_max=0
w_min=10**10

for i in range(n):
  x,y=nii()
  z=x-y
  z_max=max(z_max,z)
  z_min=min(z_min,z)

  w=x+y
  w_max=max(w_max,w)
  w_min=min(w_min,w)

ans=max(z_max-z_min,w_max-w_min)
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())

if n==1:
  print(0)
  exit()

z_max=0
z_min=10**10
w_max=0
w_min=10**10

for i in range(n):
  x,y=nii()
  z=x+y
  z_max=max(z_max,z)
  z_min=min(z_min,z)

  w=x-y
  w_max=max(w_max,w)
  w_min=min(w_min,w)

ans=max(z_max-z_min,w_max-w_min)
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())

z_max=0
z_min=10**10
w_max=0
w_min=10**10

for i in range(n):
  x,y=nii()
  z=x+y
  z_max=max(z_max,z)
  z_min=min(z_min,z)

  w=x-y
  w_max=max(w_max,w)
  w_min=min(w_min,w)

ans=max(z_max-z_min,w_max-w_min)
print(ans)

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod = 1000000007


def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1), 1)
    denom = pow(reduce(lambda x, y: x * y % mod, range(1, r + 1), 1), mod - 2, mod)
    return numer * denom % mod


def solve():
    pass


def solve01():
    n = int(input().strip())
    L = []
    Xmin, Ymin, Xmax, Ymax = (sys.maxsize, sys.maxsize, -100, -100)

    for i in range(n):
        a, b = map(int, input().strip().split())
        L.append((a, b))
        Xmin, Ymin, Xmax, Ymax = (min(Xmin, a), min(Ymin, b), max(Xmax, b), max(Ymax, b))
    A, B, C, D = ((Xmin, Ymax), (Xmin, Ymin), (Xmax, Ymin), (Xmax, Ymax))

    flag = 1
    for i in range(len(L) - 1):
        flag *= (L[i] == L[i + 1])
    if flag == 1:
        try:
            raise ValueError("error!")
        except ValueError as e:
            eprint(e)

    if Xmax == Xmin or Ymax == Ymin:
        try:
            raise ValueError("error!")
        except ValueError as e:
            eprint(e)

    # 対角線ACについて
    d_MinDistFromA = sys.maxsize    # 点Aからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromA = min(d_MinDistFromA, abs(a - Xmin) + abs(b - Ymax))

    d_MinDistFromC = sys.maxsize    # 点Cからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromC = min(d_MinDistFromC, abs(a - Xmax) + abs(b - Ymin))
    ans1 = abs(A[0] - C[0]) + abs(A[1] - C[1]) - (d_MinDistFromA + d_MinDistFromC)  #

    # 対角線BDについて
    d_MinDistFromB = sys.maxsize    # 点Bからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromB = min(d_MinDistFromB, abs(a - Xmin) + abs(b - Ymin))

    d_MinDistFromD = sys.maxsize    # 点Dからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromD = min(d_MinDistFromD, abs(a - Xmax) + abs(b - Ymax))
    ans2 = abs(B[0] - D[0]) + abs(B[1] - D[1]) - (d_MinDistFromB + d_MinDistFromD)

    # 出力
    # eprint('ans1,ans2 ', end=':\n')
    # eprint(ans1, ans2)
    print(max(ans1, ans2))


def solve00():
    n = int(input().strip())
    L = []
    Xmin = sys.maxsize
    Ymin = sys.maxsize
    Xmax = -100
    Ymax = -100
    for i in range(n):
        a, b = map(int, input().strip().split())
        L.append((a, b))
        Xmin = min(Xmin, a)
        Ymin = min(Ymin, b)
        Xmax = max(Xmax, b)
        Ymax = max(Ymax, b)

    A = (Xmin, Ymax)
    B = (Xmin, Ymin)
    C = (Xmax, Ymin)
    D = (Xmax, Ymax)

    # 対角線ACについて
    d_MinDistFromA = sys.maxsize    # 点Aからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromA = min(d_MinDistFromA, abs(a - Xmin) + abs(b - Ymax))

    d_MinDistFromC = sys.maxsize    # 点Cからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromC = min(d_MinDistFromC, abs(a - Xmax) + abs(b - Ymin))
    ans1 = abs(A[0] - C[0]) + abs(A[1] - C[1]) - (d_MinDistFromA + d_MinDistFromC)  #

    # 対角線BDについて
    d_MinDistFromB = sys.maxsize    # 点Bからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromB = min(d_MinDistFromB, abs(a - Xmin) + abs(b - Ymin))

    d_MinDistFromD = sys.maxsize    # 点Dからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromD = min(d_MinDistFromD, abs(a - Xmax) + abs(b - Ymax))
    ans2 = abs(B[0] - D[0]) + abs(B[1] - D[1]) - (d_MinDistFromB + d_MinDistFromD)

    # 出力
    # eprint('ans1,ans2 ', end=':\n')
    # eprint(ans1, ans2)
    print(max(ans1, ans2))


def main():
    solve01()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod = 1000000007


def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1), 1)
    denom = pow(reduce(lambda x, y: x * y % mod, range(1, r + 1), 1), mod - 2, mod)
    return numer * denom % mod


def solve():
    pass


def solve01():
    n = int(input().strip())
    L = []
    Xmin, Ymin, Xmax, Ymax = (sys.maxsize, sys.maxsize, -100, -100)

    for i in range(n):
        a, b = map(int, input().strip().split())
        L.append((a, b))
        Xmin, Ymin, Xmax, Ymax = (min(Xmin, a), min(Ymin, b), max(Xmax, b), max(Ymax, b))
    A, B, C, D = ((Xmin, Ymax), (Xmin, Ymin), (Xmax, Ymin), (Xmax, Ymax))

    
    flag=1
    for i in range(len(L)-1):
        flag *= (L[i] == L[i+1])
    if flag==1:
        try:
            raise ValueError("error!")
        except ValueError as e:
            eprint(e)

    # 対角線ACについて
    d_MinDistFromA = sys.maxsize    # 点Aからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromA = min(d_MinDistFromA, abs(a - Xmin) + abs(b - Ymax))

    d_MinDistFromC = sys.maxsize    # 点Cからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromC = min(d_MinDistFromC, abs(a - Xmax) + abs(b - Ymin))
    ans1 = abs(A[0] - C[0]) + abs(A[1] - C[1]) - (d_MinDistFromA + d_MinDistFromC)  #

    # 対角線BDについて
    d_MinDistFromB = sys.maxsize    # 点Bからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromB = min(d_MinDistFromB, abs(a - Xmin) + abs(b - Ymin))

    d_MinDistFromD = sys.maxsize    # 点Dからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromD = min(d_MinDistFromD, abs(a - Xmax) + abs(b - Ymax))
    ans2 = abs(B[0] - D[0]) + abs(B[1] - D[1]) - (d_MinDistFromB + d_MinDistFromD) #

    # 出力
    # eprint('ans1,ans2 ', end=':\n')
    # eprint(ans1, ans2)
    print(max(ans1, ans2))


def solve00():
    n = int(input().strip())
    L = []
    Xmin = sys.maxsize
    Ymin = sys.maxsize
    Xmax = -100
    Ymax = -100
    for i in range(n):
        a, b = map(int, input().strip().split())
        L.append((a, b))
        Xmin = min(Xmin, a)
        Ymin = min(Ymin, b)
        Xmax = max(Xmax, b)
        Ymax = max(Ymax, b)

    A = (Xmin, Ymax)
    B = (Xmin, Ymin)
    C = (Xmax, Ymin)
    D = (Xmax, Ymax)

    # 対角線ACについて
    d_MinDistFromA = sys.maxsize    # 点Aからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromA = min(d_MinDistFromA, abs(a - Xmin) + abs(b - Ymax))

    d_MinDistFromC = sys.maxsize    # 点Cからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromC = min(d_MinDistFromC, abs(a - Xmax) + abs(b - Ymin))
    ans1 = abs(A[0] - C[0]) + abs(A[1] - C[1]) - (d_MinDistFromA + d_MinDistFromC)  #

    # 対角線BDについて
    d_MinDistFromB = sys.maxsize    # 点Bからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromB = min(d_MinDistFromB, abs(a - Xmin) + abs(b - Ymin))

    d_MinDistFromD = sys.maxsize    # 点Dからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromD = min(d_MinDistFromD, abs(a - Xmax) + abs(b - Ymax))
    ans2 = abs(B[0] - D[0]) + abs(B[1] - D[1]) - (d_MinDistFromB + d_MinDistFromD)

    # 出力
    # eprint('ans1,ans2 ', end=':\n')
    # eprint(ans1, ans2)
    print(max(ans1, ans2))


def main():
    solve01()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod = 1000000007


def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1), 1)
    denom = pow(reduce(lambda x, y: x * y % mod, range(1, r + 1), 1), mod - 2, mod)
    return numer * denom % mod


def solve():
    pass


def main():
    n = int(input().strip())
    L = []
    Xmin = sys.maxsize
    Ymin = sys.maxsize
    Xmax = -100
    Ymax = -100
    for i in range(n):
        a, b = map(int, input().strip().split())
        L.append((a, b))
        Xmin = min(Xmin, a)
        Ymin = min(Ymin, b)
        Xmax = max(Xmax, b)
        Ymax = max(Ymax, b)

    A = (Xmin, Ymax)
    B = (Xmin, Ymin)
    C = (Xmax, Ymin)
    D = (Xmax, Ymax)

    # 対角線ACについて
    d_MinDistFromA = sys.maxsize    # 点Aからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromA = min(d_MinDistFromA, abs(a - Xmin) + abs(b - Ymax))

    d_MinDistFromC = sys.maxsize    # 点Cからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromC = min(d_MinDistFromC, abs(a - Xmax) + abs(b - Ymin))
    ans1 = abs(A[0] - C[0]) + abs(A[1] - C[1]) - (d_MinDistFromA + d_MinDistFromC)  #

    # 対角線BDについて
    d_MinDistFromB = sys.maxsize    # 点Bからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromB = min(d_MinDistFromB, abs(a - Xmin) + abs(b - Ymin))

    d_MinDistFromD = sys.maxsize    # 点Dからの距離が最小であるような，その最小の距離の値を求める
    for a, b in L:
        d_MinDistFromD = min(d_MinDistFromD, abs(a - Xmax) + abs(b - Ymax))
    ans2 = abs(B[0] - D[0]) + abs(B[1] - D[1]) - (d_MinDistFromB + d_MinDistFromD)

    # 出力
    # eprint('ans1,ans2 ', end=':\n')
    # eprint(ans1, ans2)
    print(max(ans1, ans2))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod = 1000000007


def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1), 1)
    denom = pow(reduce(lambda x, y: x * y % mod, range(1, r + 1), 1), mod - 2, mod)
    return numer * denom % mod


def solve():
    pass


def main():
    n = int(input().strip())
    L = []
    Xmin = sys.maxsize
    Ymin = sys.maxsize
    Xmax = -100
    Ymax = -100
    for i in range(n):
        a, b = map(int, input().strip().split())
        L.append((a, b))
        Xmin = min(Xmin, a)
        Ymin = min(Ymin, b)
        Xmax = max(Xmax, b)
        Ymax = max(Ymax, b)

    A = (Xmin, Ymax)
    B = (Xmin, Ymin)
    C = (Xmax, Ymin)
    D = (Xmax, Ymax)

    # AC
    d_MinDistFromA = sys.maxsize
    for a, b in L:
        d_MinDistFromA = min(d_MinDistFromA, abs(a - Xmin) + abs(b - Ymax))

    d_MinDistFromC = sys.maxsize
    for a, b in L:
        d_MinDistFromC = min(d_MinDistFromC, abs(a - Xmin) + abs(b - Ymax))
    ans1 = abs(A[0] - C[0]) + abs(A[1] - C[1]) - (d_MinDistFromA + d_MinDistFromC)

    #
    d_MinDistFromB = sys.maxsize
    for a, b in L:
        d_MinDistFromB = min(d_MinDistFromB, abs(a - Xmin) + abs(b - Ymax))

    d_MinDistFromD = sys.maxsize
    for a, b in L:
        d_MinDistFromD = min(d_MinDistFromD, abs(a - Xmin) + abs(b - Ymax))
    ans2 = abs(B[0] - D[0]) + abs(B[1] - D[1]) - (d_MinDistFromB + d_MinDistFromD)

    print(max(ans1, ans2))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod = 1000000007


def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1), 1)
    denom = pow(reduce(lambda x, y: x * y % mod, range(1, r + 1), 1), mod - 2, mod)
    return numer * denom % mod


def solve():
    pass


def main():
    n = int(input().strip())
    L = []
    Xmin = sys.maxsize
    Ymin = sys.maxsize
    Xmax = -100
    Ymax = -100
    for i in range(n):
        a, b = map(int, input().strip().split())
        L.append((a, b))
        Xmin = min(Xmin, a)
        Ymin = min(Ymin, b)
        Xmax = max(Xmax, b)
        Ymax = max(Ymax, b)

    A = (Xmin, Ymax)
    B = (Xmin, Ymin)
    C = (Xmax, Ymin)
    D = (Xmax, Ymax)

    #
    d_MinDistFromA = sys.maxsize
    for a, b in L:
        d_MinDistFromA = min(d_MinDistFromA, abs(a - Xmin) + abs(b - Ymax))

    d_MinDistFromC = sys.maxsize
    for a, b in L:
        d_MinDistFromC = min(d_MinDistFromC, abs(a - Xmin) + abs(b - Ymax))
    ans1 = abs(A[0] - C[0]) + abs(A[1] - C[1]) - (d_MinDistFromA + d_MinDistFromC)

    #
    d_MinDistFromB = sys.maxsize
    for a, b in L:
        d_MinDistFromB = min(d_MinDistFromB, abs(a - Xmin) + abs(b - Ymax))

    d_MinDistFromD = sys.maxsize
    for a, b in L:
        d_MinDistFromD = min(d_MinDistFromD, abs(a - Xmin) + abs(b - Ymax))
    ans2 = abs(B[0] - D[0]) + abs(B[1] - D[1]) - abs(d_MinDistFromB + d_MinDistFromD)

    print(min(ans1, ans2))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod = 1000000007


def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1), 1)
    denom = pow(reduce(lambda x, y: x * y % mod, range(1, r + 1), 1), mod - 2, mod)
    return numer * denom % mod


def solve():
    pass


def main():
    n = int(input().strip())
    L = []
    Xmin = sys.maxsize
    Ymin = sys.maxsize
    Xmax = -100
    Ymax = -100
    for i in range(n):
        a, b = map(int, input().strip().split())
        L.append((a, b))
        Xmin = min(Xmin, a)
        Ymin = min(Ymin, b)
        Xmax = max(Xmax, b)
        Ymax = max(Ymax, b)

    A = (Xmin, Ymax)
    B = (Xmin, Ymin)
    C = (Xmax, Ymin)
    D = (Xmax, Ymax)

    #
    d_MinDistFromA = sys.maxsize
    for a, b in L:
        d_MinDistFromA = min(d_MinDistFromA, abs(a - Xmin) + abs(b - Ymax))

    d_MinDistFromC = sys.maxsize
    for a, b in L:
        d_MinDistFromC = min(d_MinDistFromC, abs(a - Xmin) + abs(b - Ymax))
    ans1 = abs(A[0] - C[0]) + abs(A[1] - C[1]) - (d_MinDistFromA + d_MinDistFromC)

    #
    d_MinDistFromB = sys.maxsize
    for a, b in L:
        d_MinDistFromB = min(d_MinDistFromB, abs(a - Xmin) + abs(b - Ymax))

    d_MinDistFromD = sys.maxsize
    for a, b in L:
        d_MinDistFromD = min(d_MinDistFromD, abs(a - Xmin) + abs(b - Ymax))
    ans2 = abs(B[0] - D[0]) + abs(B[1] - D[1]) - (d_MinDistFromB + d_MinDistFromD)

    print(min(ans1, ans2))


if __name__ == '__main__':
    main()

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(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())
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]+numbers[0][1]
max_dis=numbers[0][0]+numbers[0][1]
for num in numbers:
    if num[0]**2+num[1]<min_dis:
        min_dis=num[0]+num[1]
        saishou=[num[0],num[1]]
    if num[0]+num[1]>max_dis:
        max_dis=num[0]+num[1]
        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=abs(numbers[0][0])+abs(numbers[0][1])
max_dis=abs(numbers[0][0])+abs(numbers[0][1])
for num in numbers:
    if abs(num[0])+num[1]<min_dis:
        min_dis=abs(num[0])+num[1]
        saishou=[num[0],num[1]]
    if abs(num[0])+num[1]>max_dis:
        max_dis=abs(num[0])+num[1]
        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())
mx = 0; mn = 10**9 * 2
for i in range(n):
    x, y = map(int, input().split())
    o_mh = x + y
    mx = max(mx, o_mh)
    mn = min(mn, o_mh)
print(mx - mn)