Problem:


Score: 300 points

Problem Statement

In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.

The pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0).  

Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:  

C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1.  

Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i."  

This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.  

Constraints

N is an integer between 1 and 100 (inclusive).

x_i and y_i are integers between 0 and 100 (inclusive).

h_i is an integer between 0 and 10^9 (inclusive).

The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.

The center coordinates and the height of the pyramid can be uniquely identified.

Input

Input is given from Standard Input in the following format:  

N
x_1 y_1 h_1
x_2 y_2 h_2
x_3 y_3 h_3
:
x_N y_N h_N

Output

Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.  

Sample Input 1

4
2 3 5
2 1 5
1 2 5
3 2 5

Sample Output 1

2 2 6

In this case, the center coordinates and the height can be identified as (2, 2) and 6.  

Sample Input 2

2
0 0 100
1 1 98

Sample Output 2

0 0 100

In this case, the center coordinates and the height can be identified as (0, 0) and 100.

Note that C_X and C_Y are known to be integers between 0 and 100.

Sample Input 3

3
99 1 191
100 1 192
99 0 192

Sample Output 3

100 0 193

In this case, the center coordinates and the height can be identified as (100, 0) and 193.  



Sample input:
4
2 3 5
2 1 5
1 2 5
3 2 5


Sample output:
2 2 6

Submission status: Wrong Answer

Solution code:
n = int(input())

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

x, y, h = sorted(dots, key=lambda x: x[2], reverse=True)[1]

for cx in range(101):
    for cy in range(101):
        H = h+abs(x - cx) + abs(y-cy)

        ans = []
        for x, y, h in dots:
            if max(H - abs(x-cx)-abs(y-cy), 0) == h:
                ans.append((cx, cy, H))

        if len(ans) == n:
            print(*ans[0])
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

dots = []

for _ in range(n):
    x, y, h = map(int, input().split())
    dots.append((x, y, h))

dots = sorted(dots, key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        h_ls = []
        for i in range(n):
            h = dots[i][2]+abs(dots[i][0] - cx) + abs(dots[i][1]-cy)
            h_ls.append(h)

        if len(set(h_ls)) == 1:
            print(cx, cy, h_ls[0])
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

dots = []

for _ in range(n):
    x, y, h = map(int, input().split())
    dots.append((x, y, h))

for cx in range(101):
    for cy in range(101):
        h_ls = []
        for i in range(n):
            h = dots[i][2]+abs(dots[i][0] - cx) + abs(dots[i][1]-cy)
            h_ls.append(h)

        if len(set(h_ls)) == 1 and h_ls[0] >= 1:
            print(cx, cy, h_ls[0])
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

dots = []

for _ in range(n):
    x, y, h = map(int, input().split())
    dots.append((x, y, h))

for cx in range(101):
    for cy in range(101):
        h_ls = []
        for i in range(n):
            a = dots[i][2]+abs(dots[i][0] - cx) + abs(dots[i][1]-cy)
            h_ls.append(a)

        if len(set(h_ls)) == 1:
            print(cx, cy, h_ls[0])
            exit()

Submission status: Wrong Answer

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

A0 = [] 
for i in range(N):
    if A[i][2] == 0:
        A0.append(A[i])
A1 = []
for i in range(N):
    if A[i][2] != 0:
        A1.append(A[i])
#print(A0,A1)

B = []
for X in range(101):
    cnt = 0
    H = 0
    H1 = 0
    for Y in range(101):
        cnt = 0
        H = 0
        H1 = 0
        for i in range(N-len(A0)):
            H = A1[i][2] + abs(X - A1[i][0]) + abs(Y - A1[i][1])
            if  H == H1:
                cnt += 1
                H1 = H
            if cnt >= N-1-len(A0):
                B.append((X, Y, H))
            H1 = H
print(B[0][0] ,B[0][1] ,B[0][2] )

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
X = []
Y = []
H = []
ans = ()
for i in range(n):
    x, y, h = LI()
    if h:
        r = i
    X += [x]
    Y += [y]
    H += [h]




for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = X[r], Y[r], H[r]
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for i in range(n):
            if H[i] != h - abs(cx - X[i]) - abs(cy - Y[i]):
                break
        else:
            print(cx, cy, h)
            exit()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
X = []
Y = []
H = []
ans = ()
for _ in range(n):
    x, y, h = LI()
    if h:
        X += [x]
        Y += [y]
        H += [h]

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = X[0], Y[0], H[0]
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for i in range(1, len(X)):
            if H[i] != h - abs(cx - X[i]) - abs(cy - Y[i]):
                break
        else:
            print(cx, cy, h)
            exit()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
X = []
Y = []
H = []
ans = ()
for _ in range(n):
    x, y, h = LI()
    if h == 100:
        ans = (x, y, h)
    elif h:
        X += [x]
        Y += [y]
        H += [h]

if ans:
    print(*ans)
    exit()


for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = X[0], Y[0], H[0]
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for i in range(1, len(X)):
            if H[i] != h - abs(cx - X[i]) - abs(cy - Y[i]):
                break
        else:
            print(cx, cy, h)
            exit()

Submission status: Wrong Answer

Solution code:
def check_h(x, y, xy_):
    difference_h = abs(x-xy_[0]) + abs(y-xy_[1])
    return difference_h

def main():
    n = int(input())
    xyh = [list(map(int, input().split())) for _ in range(n)]

    for x_, y_, h_ in xyh:
        if h_ != 0:
            X, Y, H = x_, y_, h_
            break

    for i in range(101):
        for j in range(101):
            xy = [i, j]
            h = H + check_h(X, Y, xy)
            if h >= H:
                if all(xyh[s][2]==max(h-check_h(xyh[s][0], xyh[s][1], xy), 0) for s in range(1,n)):
                    print(i, j, h)
                    break
    return 0

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def check_h(x, y, xy_):
    difference_h = abs(x-xy_[0]) + abs(y-xy_[1])
    return difference_h

def main():
    n = int(input())
    xyh = [list(map(int, input().split())) for _ in range(n)]

    for x_, y_, h_ in xyh:
        if h_ != 0:
            X, Y, H = x_, y_, h_
            break

    for i in range(101):
        for j in range(101):
            xy = [i, j]
            h = H + check_h(X, Y, xy)
            if h < H:
                continue
            if all(xyh[s][2]==max(h-check_h(xyh[s][0], xyh[s][1], xy), 0) for s in range(1,n)):
                print(i, j, h)
                break
    return 0

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def check_h(x, y, xy_):
    difference_h = abs(x-xy_[0]) + abs(y-xy_[1])
    return difference_h

def main():
    n = int(input())
    xyh = [list(map(int, input().split())) for _ in range(n)]

    for x_, y_, h_ in xyh:
        if h_ != 0:
            X, Y, H = x_, y_, h_
            break

    for i in range(101):
        for j in range(101):
            xy = [i, j]
            h = H + check_h(X, Y, xy)
            if all(xyh[s][2]==max(h-check_h(xyh[s][0], xyh[s][1], xy), 0) for s in range(1,n)):
                print(i, j, h)
                break
    return 0

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def check_h(x, y, xy_):
    difference_h = abs(x-xy_[0]) + abs(y-xy_[1])
    return difference_h

def main():
    n = int(input())
    xyh = [list(map(int, input().split())) for _ in range(n)]

    for i in range(101):
        for j in range(101):
            xy = [i, j]
            h = xyh[0][2] + check_h(xyh[0][0], xyh[0][1], xy)
            if all(xyh[s][2]==max(h-check_h(xyh[s][0], xyh[s][1], xy), 0) for s in range(1,n)):
                print(i, j, h)
                break
    return 0

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
def check_h(x, y, xy_):
    difference_h = abs(x-xy_[0]) + abs(y-xy_[1])
    return difference_h

def main():
    n = int(input())
    xyh = [list(map(int, input().split())) for _ in range(n)]

    for i in range(101):
        for j in range(101):
            xy = [i, j]
            h = xyh[0][2] + check_h(xyh[0][0], xyh[0][1], xy)
            if all(h==xyh[s][2]+check_h(xyh[s][0], xyh[s][1], xy) for s in range(1,n)):
                print(i, j, h)
                break
    return 0

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
xyh=[list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x: x[2],reverse=True)

for x in range(101):
    for y in range(101):
        ans=True
        H=xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1])
        for n in range(1,N):
            if H!=xyh[n][2]+abs(x-xyh[n][0])+abs(y-xyh[n][1]) and xyh[n][2]!=0:
                ans=False
                break
        if ans:
            print(x,y,H)
            exit()

Submission status: Wrong Answer

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


for x in range(101):
    for y in range(101):
        ans=True
        H=xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1])
        for n in range(1,N):
            if H!=xyh[n][2]+abs(x-xyh[n][0])+abs(y-xyh[n][1]) and xyh[n][2]!=0:
                ans=False
                break
        if ans:
            print(x,y,H)
            exit()

Submission status: Wrong Answer

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


for x in range(101):
    for y in range(101):
        ans=True
        H=xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1])
        for n in range(1,N):
            if H!=xyh[n][2]+abs(x-xyh[n][0])+abs(y-xyh[n][1]):
                ans=False
                break
        if ans:
            print(x,y,H)
            exit()

Submission status: Wrong Answer

Solution code:
def High(cx, cy, x, y, h):
    return h + abs(x-cx) + abs(y-cy)

def high(cx, cy, x, y, High):
    return max(High - abs(x-cx) - abs(y-cy), 0)

n = int(input())
l = sorted([list(map(int, input().split())) for _ in range(n)], reverse=1)

for i in range(101):
    for j in range(101):
        H = High(l[0][0], l[0][1], i, j, l[0][2])
        for k in l[1:]:
            if high(k[0], k[1], i, j, H) != k[2]:
                break
        else:
            print(i, j, H)
            break

Submission status: Wrong Answer

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

l.sort(key=lambda x:-x[2])

for i in range(101):
    for j in range(101):
        h = l[0][0] - i + l[0][1] - j + l[0][2]
        if h<=0:
            continue

        ok=True
        for k in range(len(l)):
            tmp_h = max(h - abs(l[k][0] - i) - abs(l[k][1] - j),0)
            if tmp_h != l[k][2]:
                ok=False
                break
        if ok:
            print(i,j,h)
            exit()

Submission status: Wrong Answer

Solution code:
arr = []
n = int(input())

for i in range(n):
    arr.append([int(s) for s in input().split(" ")])



import math

def calculate(n, arr):
    for i in range(101):
        for j in range(101):

            centerH = -100

            for ar in arr:
                posX = ar[0]
                posY = ar[1]
                posH = ar[2]

                if posH == 0:
                    if centerH > int(math.fabs(i - posX)) + int(math.fabs(j - posY)):
                        continue

                if centerH == -100:
                    if posH == 0:
                        if centerH > int(math.fabs(i - posX)) + int(math.fabs(j - posY)):
                            continue
                    centerH = posH + int(math.fabs(i - posX)) + int(math.fabs(j - posY))
                    continue

                tmp = posH + int(math.fabs(i - posX)) + int(math.fabs(j - posY))

                if tmp == centerH:
                    centerH = tmp
                    continue

                else:
                    centerH = -1
                    break


            if centerH != -1:
                print(i,j,centerH)
                break


calculate(n, arr)

Submission status: Wrong Answer

Solution code:

arr = []
n = int(input())

for i in range(n):
    arr.append([int(s) for s in input().split(" ")])



import math

def calculate(n, arr):
    for i in range(101):
        for j in range(101):

            centerH = -100

            for ar in arr:
                posX = ar[0]
                posY = ar[1]
                posH = ar[2]

                if posH == 0:
                    if centerH > int(math.fabs(i - posX)) + int(math.fabs(j - posY)):
                        continue

                if centerH == -100:
                    centerH = posH + int(math.fabs(i - posX)) + int(math.fabs(j - posY))
                    continue

                tmp = posH + int(math.fabs(i - posX)) + int(math.fabs(j - posY))

                if tmp == centerH:
                    centerH = tmp
                    continue

                else:
                    centerH = -1
                    break


            if centerH > 0:
                print(i,j,centerH)
                break


calculate(n, arr)

Submission status: Wrong Answer

Solution code:

arr = []
n = int(input())

for i in range(n):
    arr.append([int(s) for s in input().split(" ")])



import math

def calculate(n, arr):
    for i in range(101):
        for j in range(101):

            centerH = -100

            for ar in arr:
                posX = ar[0]
                posY = ar[1]
                posH = ar[2]

                if centerH == -100:
                    centerH = posH + int(math.fabs(i - posX)) + int(math.fabs(j - posY))
                    continue

                tmp = posH + int(math.fabs(i - posX)) + int(math.fabs(j - posY))

                if tmp == centerH:
                    centerH = tmp
                    continue

                else:
                    centerH = -1
                    break


            if centerH > 0:
                print(i,j,centerH)
                break


calculate(n, arr)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for x in range(101):
    for y in range(101):
        b = True
        H = -1
        for i in range(N):
            H = max(H,abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2])
        for j in range(N):
            if xyh[j][2] != max(H - abs(xyh[j][0]-x) - abs(xyh[j][1]-y), 0):
                b = False
                break
        if b:
            break
    if b:
        break
print(x,y,H)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for x in range(101):
    for y in range(101):
        b = True
        H = 10**9+7
        for i in range(N):
            H = min(H,abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2])
        for j in range(N):
            if xyh[j][2] != max(H - abs(xyh[j][0]-x) - abs(xyh[j][1]-y), 0):
                b = False
                break
        if b:
            break
    if b:
        break
print(x,y,H)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for x in range(101):
    for y in range(101):
        b = True
        Hmax = 10**9+7
        H = 10**9+7
        for i in range(N):
            if xyh[i][2] != 0:
                H = abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]
                break
            else:
                Hmax = min(abs(xyh[i][0]-x) + abs(xyh[i][1]-y),Hmax)
        if Hmax < H:
            H = Hmax
        for j in range(N):
            if xyh[j][2] != max(H - abs(xyh[j][0]-x) - abs(xyh[j][1]-y), 0):
                b = False
                break
        if b:
            break
    if b:
        break
print(x,y,H)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for x in range(101):
    for y in range(101):
        b = True
        Hmax = 10**9+7
        H = 10**9+7
        for i in range(N):
            if xyh[i][2] != 0:
                H = abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]
                break
            else:
                Hmax = min(abs(xyh[i][0]-x) + abs(xyh[i][1]-y),Hmax)
        for j in range(i,N):
            if xyh[j][2] != max(H - abs(xyh[j][0]-x) - abs(xyh[j][1]-y), 0):
                b = False
                break
        if b:
            break
    if b:
        break
if H == 10**9+7:
    H = Hmax
print(x,y,H)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
plot = []
for i in range(n):
    x, y, h = map(int, input().split())
    plot.append([x,y,h])

for cx in range(101):
    for cy in range(101):
        d = set()
        for i in range(n):
            h = 0
            if plot[i][2] > 0:
                h = abs(plot[i][0] - cx) + abs(plot[i][1] - cy) + plot[i][2]
                d.add(h)
        if len(d) == 1:
            print(cx,cy,list(d)[0])
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for x in range(101):
    for y in range(101):
        b = True
        for i in range(N):
            if xyh[i][2] != 0:
                H = abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]
                break
        for j in range(i,N):
            if xyh[j][2] != max(H - abs(xyh[j][0]-x) - abs(xyh[j][1]-y), 0):
                b = False
                break
        if b:
            break
    if b:
        break
print(x,y,H)

Submission status: Wrong Answer

Solution code:
N = int(input())
X, Y, H = [], [], []
target = None
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
    if h >= 1:
        target = (x, y, h)

for cx in range(101):
    for cy in range(101):
        v = target[2] + abs(target[0] - cx) + abs(target[1] - cy)
        v = max(v, 0)
        flag = True
        for x, y, h in zip(X, Y, H):
            vv = v - abs(x - cx) - abs(y - cy)
            if h != vv:
                flag = False
                break
        if flag:
            print(cx, cy, v)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h >= 1:
        X.append(x)
        Y.append(y)
        H.append(h)

for cx in range(101):
    for cy in range(101):
        s = set()
        for x, y, h in zip(X, Y, H):
            dh = abs(cx - x) + abs(cy - y) + h
            s.add(dh)

        if len(s) == 1:
            print(cx, cy, *s)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
for cx in range(101):
    for cy in range(101):
        s = set()
        for x, y, h in zip(X, Y, H):
            dh = abs(cx - x) + abs(cy - y) + h
            s.add(dh)

        if len(s) == 1:
            print(cx, cy, *s)
            exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
XYH = np.array([input().split() for _ in range(N)], dtype=np.int64)
X, Y, H = XYH[XYH[:, 2] != 0].T
for Cx in range(101):
    for Cy in range(101):
        estimated_heights = set(H + np.abs(X - Cx) + np.abs(Y - Cy))
        if len(estimated_heights) == 1:
            print(Cx, Cy, *estimated_heights)
            quit()

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
X, Y, H = np.array([input().split() for _ in range(N)], dtype=np.int64).T

for Cx in range(101):
    for Cy in range(101):
        estimated_heights = set(H + np.abs(X - Cx) + np.abs(Y - Cy))
        if len(estimated_heights) == 1:
            print(Cx, Cy, *estimated_heights)
            quit()

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n=int(input())
data=[]
for i in range(n):
    x0,y0,h0=map(int,input().split())
    data.append([h0,x0,y0])
data.sort(reverse=True)
if n==1:
    print(data[0][0],data[0][1],data[0][2])
else:
    x=0
    y=0
    buf=0
    for cx in range(101):
        buf=0
        for cy in range(101):
            buf=0
            h=data[0][0]+abs(data[0][1]-cx)+abs(data[0][2]-cy)
            for i in range(1,n):
                if data[i][0]==0:
                    break
                else: 
                    h_i=data[i][0]+abs(data[i][1]-cx)+abs(data[i][2]-cy)
                    if h_i!=h:
                        buf=1
                        break
            if buf==0:
                x=cx
                y=cy
                break
        if buf==0:
            break
    print(x,y,h)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
I = 0
for i in range(n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    if c > 0:
        I = i
H = 0
X = Y = 0
flag = 0
for i in range(101):
    for j in range(101):
        tmp = abs(x[I]-i) + abs(y[I]-j) + h[I]
        for k in range(n):
            if h[k] > 0:
                if tmp != abs(x[k]-i) + abs(y[k]-j) + h[k]:
                    break
        else:
            H = tmp
            X = i
            Y = j
print(X, Y, H)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for _ in range(n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
H = 0
X = Y = 0
flag = 0
for i in range(101):
    for j in range(101):
        tmp = []
        for k in range(n):
            if h[k] > 0:
                tmp.append(abs(x[k]-i) + abs(y[k]-j) + h[k])
            if len(set(tmp)) > 1:
                break
        else:
            H = tmp[0]
            X = i
            Y = j
print(X, Y, H)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for _ in range(n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
H = 0
X = Y = 0
for i in range(101):
    for j in range(101):
        tmp = abs(x[0]-i) + abs(y[0]-j) + h[0]
        for k in range(n):
            if tmp != abs(x[k]-i) + abs(y[k]-j) + h[k]:
                break
        else:
            H = tmp
            X = i
            Y = j
print(X, Y, H)

Submission status: Wrong Answer

Solution code:
N = int(input())
P = [tuple(map(int, input().split())) for i in range(N)]
_x, _y, _h = max(P, key=lambda x: x[2])

for cx in range(101):
  for cy in range(101):
    H = _h + abs(_x - cx) + abs(_y - cy)
    if all([H - abs(x-cx) - abs(y-cy) == h for x, y, h in P]):
      print(cx, cy, H)
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
P = [tuple(map(int, input().split())) for i in range(N)]

for cx in range(101):
  for cy in range(101):
    H = -1
    for i in range(N):
      x, y, h = P[i]
      if h == 0: continue
      h += abs(x-cx) + abs(y-cy)
      if H == -1: H = h
      if H != h: break
    else:
      print(cx, cy, H)
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
P = [tuple(map(int, input().split())) for i in range(N)]

for cx in range(101):
  for cy in range(101):
    H = 0
    for x, y, h in P:
      h += abs(x-cx) + abs(y-cy)
      H = max(H, h)
    if all([h == max(H - abs(x-cx) - abs(y-cy), 0) for x, y, h in P]):
      print(cx, cy, H)
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
P = [tuple(map(int, input().split())) for i in range(N)]

for cx in range(101):
  for cy in range(101):
    H = -1
    for x, y, h in P:
      h += abs(x-cx) + abs(y-cy)
      H = max(H, h)
    if all([h == max(H - abs(x-cx) - abs(y-cy), 0) for x, y, h in P]):
      print(cx, cy, H)
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
P = [tuple(map(int, input().split())) for i in range(N)]

for cx in range(101):
  for cy in range(101):
    H = -1
    for i in range(N):
      x, y, h = P[i]
      h += abs(x-cx) + abs(y-cy)
      if H == -1: H = h
      if H != h: break
    else:
      print(cx, cy, H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    XYH = [tuple(map(int, input().split())) for _ in range(N)]

    H = -1
    for x in range(0, 101):
        for y in range(0, 101):
            for xi, yi, hi in XYH:
                abs_xy = abs(x - xi) + abs(y - yi)
                if H < 0 and hi > 0:
                    H = hi + abs_xy
                elif hi != max(H - abs_xy, 0):
                    H = -1
                    break
            else:
                if H > 0:
                    print(x, y, H)
                    exit()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    XYH = [tuple(map(int, input().split())) for _ in range(N)]

    H = -1
    for x in range(0, 101):
        for y in range(0, 101):
            for xi, yi, hi in XYH:
                abs_xy = abs(x - xi) + abs(y - yi)
                if H < 0 and hi > 0:
                    H = hi + abs_xy
                elif hi != max(H - abs_xy, 0):
                    H = -1
                    break
            else:
                print(x, y, H)
                exit()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    XYH = [tuple(map(int, input().split())) for _ in range(N)]

    H = -1
    for x in range(0, 101):
        for y in range(0, 101):
            for xi, yi, hi in XYH:
                if H < 0:
                    H = hi + abs(x - xi) + abs(y - yi)
                elif hi != max(H - abs(x - xi) - abs(y - yi), 0):
                    H = -1
                    break
            else:
                print(x, y, H)
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
xyh=[]
for i in range(N):
    xyh.append(list(map(int,input().split())))
xyh.sort(key=lambda x: x[2])

for x in range(101):
    for y in range(101):
        flg = True
        H = xyh[-1][2] + abs(xyh[-1][0] - x) + abs(xyh[-1][1] - y)
        X = x
        Y = y
        
        for i in range(N):
            if H != xyh[i][2] + abs(xyh[i][0]-x) + abs(xyh[i][1] - y):
                flg=False
                break
        
        if flg:
            break
    if flg:
        break
print(X,Y,H)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
info = []
for i in range(N):
    info.append(list(map(int, input().split())))
# s = False
info.sort(key=lambda x: x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        flag = True
        s = False
        for i in range(N):
            x, y, h = info[i]
            if x < 0 or y < 0 or h <= 0:
                continue
            if not s:
                H = h + abs(cx - x) + abs(cy - y)
                s = True
                continue
            else:
                if H != h + abs(cx - x) + abs(cy - y):
                    flag = False
        if flag:
            print(cx, cy, H)
            exit()
ans = info[0]
for i in range(1, N):
    if ans[2] > info[i][2]:
        ans = info[i]
print(*ans)