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())
x = []
y = []
h = []

for i in range(0, n):
    xi, yi, hi = [int(i) for i in input().split(" ")]
    x.append(xi)
    y.append(yi)
    h.append(hi)

for cx in range(0, 101):
    for cy in range(0, 101):
        h_max = 10**9 + 1
        hd = -1
        f = False
        for i in range(0, n):
            ht = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
            if h[i] > 0:
                if hd == -1:
                    hd = ht
                else:
                    if hd != ht or h_max < ht:
                        f = True
                        break
            else:
                if h_max < ht:
                    f = True
                    break
                else:    
                    h_max = ht
        if not f:
            print(cx, cy, hd)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []

for i in range(0, n):
    xi, yi, hi = [int(i) for i in input().split(" ")]
    x.append(xi)
    y.append(yi)
    h.append(hi)

for cx in range(0, 101):
    for cy in range(0, 101):
        h_max = 10**9 + 1
        hd = -1
        f = False
        for i in range(0, n):
            ht = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
            if h[i] > 0:
                if hd == -1:
                    hd = ht
                else:
                    if hd != ht or h_max < ht:
                        f = True
                        break
            else:
                h_max = ht
        if not f:
            print(cx, cy, hd)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []

for i in range(0, n):
    xi, yi, hi = [int(i) for i in input().split(" ")]
    x.append(xi)
    y.append(yi)
    h.append(hi)

for cx in range(0, 101):
    for cy in range(0, 101):
        h_max = 10**9 + 1
        hd = 0
        f = False
        for i in range(0, n):
            ht = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
            if h[i] > 0:
                if hd == 0:
                    hd = ht
                else:
                    if hd != ht or h_max < ht:
                        f = True
                        break
            else:
                h_max = ht
        if not f:
            print(cx, cy, hd)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []

for i in range(0, n):
    xi, yi, hi = [int(i) for i in input().split(" ")]
    x.append(xi)
    y.append(yi)
    h.append(hi)

for cx in range(0, 101):
    for cy in range(0, 101):
        h_min = 0
        hd = 0
        f = False
        for i in range(0, n):
            ht = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
            if h[i] > 0:
                if hd == 0:
                    hd = ht
                else:
                    if hd != ht or h_min > ht:
                        f = True
                        break
            else:
                h_min = ht
        if not f:
            print(cx, cy, hd)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []

for i in range(0, n):
    xi, yi, hi = [int(i) for i in input().split(" ")]
    x.append(xi)
    y.append(yi)
    h.append(hi)

for cx in range(0, 101):
    for cy in range(0, 101):
        h_min = 0
        hd = 0
        f = False
        for i in range(0, n):
            ht = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
            if h[i] >= 0:
                if hd == 0:
                    hd = ht
                else:
                    if hd != ht or h_min > ht:
                        f = True
                        break
            else:
                h_min = ht
        if not f:
            print(cx, cy, hd)

Submission status: Wrong Answer

Solution code:
N = int(input())
zahyo = [tuple(map(int, input().split())) for _ in range(N)]
if N == 1:
    print("{} {} {}".format(*zahyo[0]))
    exit()
for cx in range(101):
    for cy in range(101):
        height_set = set([hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in zahyo if hi > 0])
        if len(height_set) == 1:
            print(cx, cy, max(height_set))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
zahyo = [tuple(map(int, input().split())) for _ in range(N)]
print(zahyo[0])
if N == 1:
    print("{} {} {}".format(*zahyo[0]))
    exit()
for cx in range(101):
    for cy in range(101):
        height_set = set([hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in zahyo if hi > 0])
        if len(height_set) == 1:
            print(cx, cy, max(height_set))
            exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        height_set = set([hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in zahyo if hi > 0])
        if len(height_set) == 1:
            print(cx, cy, max(height_set))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
zahyo = [tuple(map(int, input().split())) for _ in range(N)]
x0, y0, h0 = zahyo[0]
flag = 0

for cx in range(101):
    for cy in range(101):
        H =  h0 + abs(x0-cx) + abs(y0-cy)
        for xi, yi, hi in zahyo[1:]:
            if H != hi + abs(xi-cx) + abs(yi-cy):
                H = hi + abs(xi-cx) + abs(yi-cy)
                flag = 0
            else:
                flag += 1
                if 0 <= cx <= 100 and 0 <= cy <= 100 and flag == min(2, N-1):
                    print(cx, cy, H)
                    exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':


N = int(input().rstrip())
xyh = []
itr = 0
for i in range(N):
	a, b, c = map(int, input().rstrip().split())
	itr = max(itr, c)
	xyh.append([a, b, c])

def solve(x, y, h):
	for xyh_in in xyh:
		if xyh_in[2] != (h - abs(x - xyh_in[0]) - abs(y - xyh_in[1])):
			return False
	return True

for i in range(101):
	for j in range(101):
		for k in range(itr, itr+101):
			if solve(i, j, k):
				print(str(i) + " " + str(j) + " " + str(k))

Submission status: Wrong Answer

Solution code:
N = int(input())
zahyo = [tuple(map(int, input().split())) for _ in range(N)]
x0, y0, h0 = zahyo[0]

for cx in range(101):
    for cy in range(101):
        H = h0 + abs(x0-cx) + abs(y0-cy)
        for xi, yi, hi in zahyo[:min(10, N)]:
            if H != hi + abs(xi-cx) + abs(yi-cy):
               break
        else:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
zahyo = [tuple(map(int, input().split())) for _ in range(N)]
x0, y0, h0 = zahyo[0]

for cx in range(101):
    for cy in range(101):
        H = h0 + abs(x0-cx) + abs(y0-cy)
        for xi, yi, hi in zahyo[:min(5, N)]:
            if H != hi + abs(xi-cx) + abs(yi-cy):
               break
        else:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        h = -1
        for l in L:
            if l[2] == 0:
                pass
            else:
                if h == -1:
                    tmp = l[2] + abs(x-l[0]) + abs(y-l[1])
                h = l[2] + abs(x-l[0]) + abs(y-l[1])
                
                if tmp == h:
                    flag = 1
                    tmp = h
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break
        
if h == -1:
    print(L[0][0], L[0][1], 0)
else:
    print(gx, gy, gh)

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        h = -1
        for l in L:
            if l[2] == 0:
                pass
            else:
                if h == -1:
                    tmp = l[2] + abs(x-l[0]) + abs(y-l[1])
                h = l[2] + abs(x-l[0]) + abs(y-l[1])
                
                if tmp == h:
                    flag = 1
                    tmp = h
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break

print(gx, gy, gh)

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        h = -1
        for l in L:
            if l[2] == 0:
                pass
            else:
                if h == -1:
                    tmp = l[2] + abs(x-l[0]) + abs(y-l[1])
                h = l[2] + abs(x-l[0]) + abs(y-l[1])
                
                if tmp == h:
                    flag = 1
                    tmp = h
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                

print(gx, gy, gh)

Submission status: Wrong Answer

Solution code:
n = int(input())

li_input = list()

for i in range(n):
    li_input.append(tuple(map(int, input().split())))


for x in range(101):
    for y in range(101):
        set_H = set()
        for ipt in li_input:
            set_H.add(ipt[2] + abs(x - ipt[0]) + abs(y - ipt[1]))
        if len(set_H) == 1:
            print(x, y, set_H.pop())

Submission status: Wrong Answer

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

def main():
    for i in range(101):
        for j in range(101):
            H = []
            for x,y,h in S:
                if h==0:
                    continue
                H.append(h+abs(x-i)+abs(y-j))
            if len(H)==0:
                continue
            flg = True
            h_prev = H[0]
            for h in H:
                if h!=h_prev:
                    flg = False
                    break
                else:
                    h_prev = h
            if flg:
                print(i, j, h)
                return
    print('0')
    return

main()

Submission status: Wrong Answer

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

def main():
    for i in range(101):
        for j in range(101):
            H = []
            for x,y,h in S:
                if h==0:
                    continue
                H.append(h+abs(x-i)+abs(y-j))
            if len(H)==0:
                continue
            flg = True
            h_prev = H[0]
            for h in H:
                if h!=h_prev:
                    flg = False
                    break
                else:
                    h_prev = h
            if flg:
                print(i, j, h)
                break
        if flg:
            break

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
for i in range(N):
  L.append(list(map(int,input().split())))
p = 0
H = 0
ansx = -1
ansy = -1
for Cx in range(0,101):
  flag = True
  for Cy in range(0,101):
    for i in range(N):
      if L[i][2] > 0:
        p = L[i][2]
        H = p+abs(L[i][0]-Cx)+abs(L[i][1]-Cy)
        break
    for j in range(N):
      if L[j][2] != H-abs(L[j][0]-Cx)-abs(L[j][1]-Cy):
        flag = False
        break
      if flag:
        ansx = Cx
        ansy = Cy
        break
print(ansx,ansy,H)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    
index = h.index(max(h))
for cx in range(101):
    for cy in range(101):
        H = h[index] + abs(x[index] - cx) + abs(y[index] - cy)
        flag = True
        for i in range(n):
            if h[i] > 0:
                if H != (h[i] + abs(x[i] - cx) + abs(y[i] - cy)):
                    flag = False
            if h[i] == 0:
                if (H -  abs(x[i] - cx) + abs(y[i] - cy)) > 0:
                    flag = False
        if flag:
            print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    
index = h.index(max(h))
for cx in range(101):
    for cy in range(101):
        H = h[index] + abs(x[index] - cx) + abs(y[index] - cy)
        flag = True
        for i in range(n):
            if h[i] > 0:
                if H != h[i] + abs(x[i] - cx) + abs(y[i] - cy):
                    flag = False
            if h[i] == 0:
                if H -  abs(x[i] - cx) + abs(y[i] - cy) > 0:
                    flag = False
        if flag:
            print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    
index_max_h = h.index(max(h))
for cx in range(101):
    for cy in range(101):
        H = h[index_max_h] + abs(x[index_max_h] - cx) + abs(y[index_max_h] - cy)
        flag = True
        for i in range(n):
            if h != 0:
                if H != (h[i] + abs(x[i] - cx) + abs(y[i] - cy)):
                    flag = False
            if h == 0:
                if H - abs(x-cx) - abs(y-cy) > 0:
                    flag = False
        if flag:
            print(cx,cy,H)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(0,101):
    for j in range(0,101):
        maxh = None
        for x,y,h in data:
            test = h + abs(x-i) + abs(y-j)
            if maxh is None:
                maxh = test
            elif test != maxh:
                break
        else:
            print(i,j,maxh)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c

N = int(input())

p_l = [list(map(int, input().split())) for _ in range(N)]

temp_p = p_l[0]

for x in range(101):  # X
    for y in range(101):  # Y
        # 仮の中心
        h = temp_p[2] + abs(temp_p[1] - y) + abs(temp_p[0] - x)

        if all(max(h - abs(p[1] - y) - abs(p[0] - x), 0) == p[2] for p in p_l[1:]):
            print("{} {} {}".format(x, y, h))
            exit()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c

N = int(input())

p_l = [list(map(int, input().split())) for _ in range(N)]

temp_p = p_l[0]

for x in range(101):  # X
    for y in range(101):  # Y
        # 仮の中心
        temp_center_h = temp_p[2] + abs(temp_p[1] - y) + abs(temp_p[0] - x)

        if all(max(temp_center_h - abs(p[1] - y) - abs(p[0] - x), 0) == p[2] for p in p_l):
            print("{} {} {}".format(x, y, temp_center_h))
            exit()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c

N = int(input())

p_l = [list(map(int, input().split())) for _ in range(N)]


for i in range(101):  # X
    for j in range(101):  # Y
        # 仮の中心
        temp_center = [i, j]

        temp_p = p_l[0]
        temp_center_h = temp_p[2] + abs(temp_p[1] - temp_center[1]) + abs(temp_p[0] - temp_center[0])

        matched = True
        for p in p_l:
            es_height = max(temp_center_h - abs(p[1] - temp_center[1]) - abs(p[0] - temp_center[0]), 0)
            if es_height != p[2]:
                matched = False
                break

        if matched:
            print("{} {} {}".format(i, j, temp_center_h))
            exit()
        # else:
        #     print("{} {} {}, not matched".format(i, j, temp_h))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c

N = int(input())

p_l = [list(map(int, input().split())) for _ in range(N)]


for i in range(101):  # X
    for j in range(101):  # Y
        # 仮の中心
        temp_center = [i, j]

        temp_p = p_l[0]
        temp_center_h = temp_p[2] + abs(temp_p[1] - temp_center[1]) + abs(temp_p[0] - temp_center[0])

        matched = True
        for p in p_l:
            es_height = min(temp_center_h - abs(p[1] - temp_center[1]) - abs(p[0] - temp_center[0]), 0)
            if es_height != p[2]:
                matched = False
                break

        if matched:
            print("{} {} {}".format(i, j, temp_center_h))
            exit()
        # else:
        #     print("{} {} {}, not matched".format(i, j, temp_h))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c

N = int(input())

p_l = [list(map(int, input().split())) for _ in range(N)]


for i in range(101):
    for j in range(101):
        # 仮の中心
        temp_center = [i, j]

        temp_p = p_l[0]
        temp_center_h = temp_p[2] + abs(temp_p[1] - temp_center[1]) + abs(temp_p[0] - temp_center[0])

        matched = True
        for p in p_l:
            es_height = temp_center_h - abs(p[1] - temp_center[1]) - abs(p[0] - temp_center[0])
            if es_height != p[2]:
                matched = False
                break

        if matched:
            print("{} {} {}".format(i, j, temp_center_h))
            exit()
        # else:
        #     print("{} {} {}, not matched".format(i, j, temp_h))

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import product

N, *xyh = map(int, stdin.read().split())

xyh = list(zip(*[iter(xyh)] * 3))
xyh = [t for t in xyh if t[2] > 0]
xyh.sort(key=lambda x: x[2], reverse=True)

x1, y1, h1 = xyh[0]
if len(xyh) < 3:
    print(x1, y1, h1)
else:
    x2, y2, h2 = xyh[1]
    x3, y3, h3 = xyh[2]
    for X, Y in product(range(101), range(101)):
        H = h1 + abs(x1-X) + abs(y1-Y)
        if max(H-abs(x2-X)-abs(y2-Y), 0) == h2 and max(H-abs(x3-X)-abs(y3-Y), 0) == h3:
            print(X, Y, H)
            break

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import product

N, *xyh = map(int, stdin.read().split())
xyh = list(zip(*[iter(xyh)] * 3))

xyh.sort(key=lambda x: x[2], reverse=True)
x1, y1, h1 = xyh[0]

if N < 3:
    print(x1, y1, h1)
else:
    x2, y2, h2 = xyh[1]
    x3, y3, h3 = xyh[2]
    for X, Y in product(range(101), range(101)):
        H = h1 + abs(x1-X) + abs(y1-Y)
        if max(H-abs(x2-X)-abs(y2-Y), 0) == h2 and max(H-abs(x3-X)-abs(y3-Y), 0) == h3:
            print(X, Y, H)
            break

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
x = []
y = []
h = []
for i in range(n):
    tx, ty, th = map(int, input().split())
    if th != 0:
        x.append(tx)
        y.append(ty)
        h.append(th)
x = np.array(x)
y = np.array(y)
h = np.array(h)
for cx in range(0,101):
    for cy in range(0,101):
        tmp = h + np.abs(x - cx) + np.abs(y - cy)
        if np.max(tmp) == np.min(tmp):
            print(cx, cy, np.max(tmp))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
x = []
y = []
h = []
for i in range(n):
    tx, ty, th = map(int, input().split())
    x.append(tx)
    y.append(ty)
    h.append(th)
x = np.array(x)
y = np.array(y)
h = np.array(h)
if n == 1:
    print(x[0], y[0], h[0])
else:
    for cx in range(0,101):
        for cy in range(0,101):
            tmp = h + np.abs(x - cx) + np.abs(y - cy)
            if np.max(tmp) == np.min(tmp):
                print(cx, cy, np.max(tmp))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
x = []
y = []
h = []
for i in range(n):
    tx, ty, th = map(int, input().split())
    x.append(tx)
    y.append(ty)
    h.append(th)
x = np.array(x)
y = np.array(y)
h = np.array(h)
for cx in range(0,101):
    for cy in range(0,101):
        tmp = h + np.abs(x - cx) + np.abs(y - cy)
        if np.max(tmp) == np.min(tmp):
            print(cx, cy, np.max(tmp))

Submission status: Wrong Answer

Solution code:
n=int(input())
xi=[0]*n
yi=[0]*n
hi=[0]*n
for i in range(n):
  xi[i],yi[i],hi[i]=map(int,input().split())
for x in range(101):
  for y in range(101):
    flag=True
    for i in range(1,n):
      a=hi[0] + abs(x - xi[0]) + abs(y - yi[0])
      b=hi[i] + abs(x - xi[i]) + abs(y - yi[i])
      if hi[0] + abs(x - xi[0]) + abs(y - yi[0])!=hi[i] + abs(x - xi[i]) + abs(y - yi[i]):
        flag=False
        break
    if flag:print(x,y,hi[0] + abs(x - xi[0] + abs(y - yi[0])))

Submission status: Wrong Answer

Solution code:
def main() -> None:
    N = int(input())
    pos = [[int(i) for i in input().split()] for _ in range(N)]
    pos = sorted(pos, key=lambda x: x[2], reverse=True)
    x, y, h = pos.pop()
    for CX in range(101):
        for CY in range(101):
            H = h + abs(x - CX) + abs(y - CY)
            if all(posh == max(H - abs(posx - CX) - abs(posy - CY), 0) for posx, posy, posh in pos):
                print('{x} {y} {h}'.format(x=CX, y=CY, h=H))
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main() -> None:
    N = int(input())
    pos = [[int(i) for i in input().split()] for _ in range(N)]
    # どれでもいいので一つ引っこ抜く
    x, y, h = pos.pop()
    for CX in range(101):
        for CY in range(101):
            H = h + abs(x - CX) + abs(y - CY)
            if all(posh == max(H - abs(posx - CX) - abs(posy - CY), 0) for posx, posy, posh in pos):
                print('{x} {y} {h}'.format(x=CX, y=CY, h=H))
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main() -> None:
    N = int(input())
    pos = [[int(i) for i in input().split()] for _ in range(N)]
    # どれでもいいので一つ引っこ抜く
    x, y, h = pos.pop()
    for CX in range(101):
        for CY in range(101):
            H = h + abs(x - CX) + abs(y - CY)
            if all(posh == max(H - abs(posx - CX) - abs(posy - CY), 0) for posx, posy, posh in pos) and H > 0:
                print('{x} {y} {h} '.format(x=CX, y=CY, h=H))
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main() -> None:
    N = int(input())
    pos = [[int(i) for i in input().split()] for _ in range(N)]
    # どれでもいいので一つ引っこ抜く
    x, y, h = pos.pop()
    for CX in range(101):
        for CY in range(101):
            H = h + abs(x - CX) + abs(y - CY)
            if all(posh == max(H - abs(posx - CX) - abs(posy - CY), 0) for posx, posy, posh in pos):
                print('{x} {y} {h} '.format(x=CX, y=CY, h=H))
                exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main() -> None:
    N = int(input())
    pos = [[int(i) for i in input().split()] for _ in range(N)]
    # どれでもいいので一つ引っこ抜く
    x, y, h = pos.pop()
    for CX in range(101):
        for CY in range(101):
            H = h + abs(x - CX) + abs(y - CY)
            if all(posh == max(H - abs(posx - CX) - abs(posy - CY), 0) for posx, posy, posh in pos):
                print('{x} {y} {h} '.format(x=CX, y=CY, h=H))
                break


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        H = l[0][2]+abs(i-l[0][0])+abs(j-l[0][1])
        for k in range(1,n):
            if not l[k][2]==max(H-abs(i-l[k][0])-abs(j-l[k][1]), 0):
                break
            if k==n-1:
                print(i,j,H)
                import sys
                sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        h = l[0][2]+abs(i-l[0][0])+abs(j-l[0][1])
        if h<0:
            h=0
        for k in range(1,n):
            h_ = l[k][2]+abs(i-l[k][0])+abs(j-l[k][1])
            if h_<0:
                h_=0
            if not h==h_:
                break
            if k==n-1 and h>0:
                print(i,j,h)
                import sys
                sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        h = l[0][2]+abs(l[0][0]-i)+abs(l[0][1]-j)
        if h<0:
            h=0
        for k in range(1,n):
            h_ = l[k][2]+abs(l[k][0]-i)+abs(l[k][1]-j)
            if h_<0:
                h_=0
            if not h==h_:
                break
            if k==n-1 and h>0:
                print(i,j,h)
                import sys
                sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        h = l[0][2]+abs(l[0][0]-i)+abs(l[0][1]-j)
        if h<0:
            h=0
        for k in range(1,n):
            h_ = l[k][2]+abs(l[k][0]-i)+abs(l[k][1]-j)
            if h_<0:
                h_=0
            if not h==h_:
                break
            if k==n-1:
                print(i,j,h)
                import sys
                sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        h = l[0][2]+abs(l[0][0]-i)+abs(l[0][1]-j)
        for k in range(1,n):
            h_ = l[k][2]+abs(l[k][0]-i)+abs(l[k][1]-j)
            if not h==h_:
                break
            if k==n-1:
                print(i,j,h)
                import sys
                sys.exit()

Submission status: Wrong Answer

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

tx, ty, th = xyh[0]
for Cx in range(101):
  for Cy in range(101):
    H = th + abs(tx - Cx) + abs(ty - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      exit()

Submission status: Wrong Answer

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

li.sort()
# all search
from itertools import product
for x, y in product(range(0, 101), repeat=2):
    h0, x0, y0 = li[0]
    h = h0 + abs(x0 - x) + abs(y0 - y)
    ok = True
    for h0, x0, y0 in li[1:]:
        if h0 != max(0, h - abs(x - x0) - abs(y - y0)):
            ok = False
            break
    if ok:
        break

print(x, y, h)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = []
for _ in range(n):
    x0, y0, h0 = list(map(int, input().split()))
    if h0 > 0:
        li.append((x0, y0, h0))

# all search
from itertools import product
for x, y in product(range(0, 101), repeat=2):
    x0, y0, h0 = li[0]
    h = h0 + abs(x0 - x) + abs(y0 - y)
    ok = True
    for x0, y0, h0 in li[1:]:
        if h0 != h - abs(x - x0) - abs(y - y0):
            ok = False
            break
    if ok:
        break

print(x, y, h)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list()
for i in range(N):
  arr.append(tuple(map(int,input().split())))
for i in range(101):
  for j in range(101):
    H=None
    flag=True
    for tk in arr:
      xk,yk,hk = tk
      if hk == 0:
        continue
      if H is None:
        H = abs(i-xk)+abs(j-yk)+hk
        continue
      Hk = abs(i-xk)+abs(j-yk)+hk
      if H != Hk:
        flag=False
        break
    if flag:
      print(i,j,H)
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    if l[2] != 0:
        L.append(l)
#print(L)

for i in range(101):
    for j in range(101):
        tmp = -1
        for x in L:
            H = abs(x[0]-i) + abs(x[1]-j) + x[2]
            if H < 1:
                break
            if tmp != -1 and tmp != H:
                break
            else:
                tmp = H
        else:
            for x in L:
                if x[2]==max(0,H-abs(x[0]-i)-abs(x[1]-j)):
                    pass
                else:
                    break
            else:
                print(i,j,H)