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: Accepted

Solution code:
n = int(input())
pyr = []
for i in range(n):
    x, y, h = map(int, input().split())
    if h != 0:
        pyr.append((x, y, h))

if len(pyr) == 1:
    print(*pyr[0])
    exit()

for i in range(101):
    for j in range(101):
        cx, cy = (i, j)
        h_list = []
        for k in range(len(pyr)):
            x, y, h = pyr[k]
            h_list.append(h + abs(x - cx) + abs(y - cy))
        if len(set(h_list)) != 1:
            continue
        else:
            print(cx, cy, h_list[0])
            exit()

Submission status: Accepted

Solution code:
n = int(input())
a = []
h = []
for i in range(n):
    arr= list(map(int,input().split()))
    h.append(arr[2])
    a.append(arr)
l = [i for i in a if i[2]>0]
xt = l[0][0]
yt = l[0][1]
ht = l[0][2] 
for i in range(101):
    for j in range(101):
        h_ans = ht+abs(xt-i)+abs(yt-j)    
        if all(max(h_ans-abs(l[0]-i)-abs(l[1]-j),0) == l[2] for l in a):
            print(i,j,h_ans)
            exit()

Submission status: Accepted

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

def f(Cx,Cy,x,y,H):
    return max(H-abs(x-Cx)-abs(y-Cy),0)

for Cx in range(101):
    for Cy in range(101):
        H = 0
        flag = 1
        for i in range(N):
            x, y, h = table[i]
            if h > 0:
                H = h + abs(x-Cx) + abs(y-Cy)
                break
        for i in range(N):
            x, y, h = table[i]
            if f(Cx,Cy,x,y,H) != h:
                flag = 0
                break

        if flag:
            print(Cx,Cy,H)
            exit()

Submission status: Accepted

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
xyh.sort(key=lambda x: -x[2])
for cx in range(101):
  for cy in range(101):
    good = True
    h = xyh[0][2]+abs(cx-xyh[0][0])+abs(cy-xyh[0][1])
    for i in range(n):
      if xyh[i][2] != max(h-abs(cx-xyh[i][0])-abs(cy-xyh[i][1]), 0):
        good = False
        break
    if good:
      print(cx, cy, h)
      exit()

Submission status: Accepted

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

for i in range(N):
    if para[i][2] >= 1 :
        test = i 
        break
for c_x in range(0,101):
    for c_y in range(0,101):
        H = para[test][2] + abs(para[test][0]-c_x) + abs(para[test][1]-c_y)
        flag = True
        for i in range(N):
            if para[i][2] == max(H - abs(para[i][0]-c_x) - abs(para[i][1]-c_y),0) :
                    continue

            flag = False 
        if flag and H >=1:        
            print("{} {} {}".format(c_x,c_y,H))
            exit()

Submission status: Accepted

Solution code:
N = int(input())
x, y, h = zip(*(map(int, input().split()) for _ in range(N)))
def solve():
    for Cx in range(100 + 1):
        for Cy in range(100 + 1):
            for i in range(N):
                if h[i] > 0:
                    H = h[i] + abs(x[i] - Cx) + abs(y[i] - Cy)
                    break
            if all(map(lambda i: h[i] == max(H - abs(x[i] - Cx) - abs(y[i] - Cy), 0), range(N))):
                print(Cx, Cy, H)
                return
solve()

Submission status: Accepted

Solution code:
# 1つ見れば、マス目に対する高さが確定する
# 100件についてテスト
import numpy as np
N = int(input())
U = 100
XYH = np.array([[int(x) for x in input().split()] for _ in range(N)])
XYH = XYH[np.argsort(-XYH[:,2])] # 高い順なので0番目は正

x0,y0,h0 = XYH[0]
dx = np.abs(np.arange(U+1) - x0)
dy = np.abs(np.arange(U+1) - y0)
# そこに頂上があるとするとその高さ
H = dx[:,None] + dy[None,:] + h0
possible = np.full_like(H, True)

for x,y,h in XYH[1:]:
  dx = np.abs(np.arange(U+1) - x)
  dy = np.abs(np.arange(U+1) - y)
  possible &= (np.maximum(H-dx[:,None]-dy[None,:],0) == h)

nz = possible.nonzero()
x,y = nz[0][0], nz[1][0]
h = H[x,y]
print(x,y,h)

Submission status: Accepted

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

for Cx in range(101):        # x
    for Cy in range(101):    # y
        flg=True
        k=0
        while xyh[k][2]+abs(xyh[k][0]-Cx)+abs(xyh[k][1]-Cy) <1 or xyh[k][2]<1:
            k+=1
        H=xyh[k][2]+abs(xyh[k][0]-Cx)+abs(xyh[k][1]-Cy)
        for i in range(len(xyh)):
            if max(H-abs(xyh[i][0]-Cx)-abs(xyh[i][1]-Cy),0)!=xyh[i][2]:
                flg=False
        if flg:
            print(Cx,Cy,H)
            exit()

Submission status: Accepted

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
ansx = 0
ansy = 0
ansh = 0
for x in range(101):
  for y in range(101):
    hset = set()
    for i in range(N):
      xyhi = xyh[i]
      if xyhi[2] == 0:
        continue
      hset.add(abs(xyhi[0]-x) + abs(xyhi[1]-y) + xyhi[2])

    if len(hset) == 1 and list(hset)[0] != 0:
      flag = True
      for i in range(N):
        xyhi = xyh[i]
        if xyhi[2] != 0:
          continue
        elif xyhi[2] == 0 and max(list(hset)[0] - abs(xyhi[0]-x) - abs(xyhi[1]-y), 0) == 0:
          continue
        flag = False
        break
      if flag:
        ansx = x
        ansy = y
        ansh = list(hset)[0]

print(ansx, ansy, ansh)

Submission status: Accepted

Solution code:
N = int(input())
X = [0]*N
Y = [0]*N
H = [0]*N
for i in range(N):
    X[i],Y[i],H[i] = map(int, input().split())

# print(N, X, Y, H)

point = []
for n in range(N):
    if H[n] != 0:
        point = [X[n], Y[n], H[n]]
        break

ans = []
same = True
for i in range(101):
    for j in range(101):
        same = True
        height = point[2] + abs(point[0] - i) + abs(point[1] - j)
        for n in range(N):
            x = X[n]
            y = Y[n]
            h = H[n]
            candidate = max(height - abs(x - i) - abs(y - j), 0)
            if candidate != h:
                same = False
                break
        if same:
            ans = [i, j, height]
            break
    if same:
        break

if same:
    print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        H = 0
        ok = True
        for i in range(N):
            x,y,h = xyh[i]
            if h != 0:
                if H == 0:
                    H = h+abs(cx-x)+abs(cy-y)
                else:
                    ok = H==h+abs(cx-x)+abs(cy-y)
            else:
                ok = abs(cx-x)+abs(cy-y)-H>=0
            if not ok:
                break
        if ok:
            break
    if ok:
        break
    
print('{} {} {}'.format(cx,cy,H))

Submission status: Accepted

Solution code:

N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        H = 0
        ok = True
        for i in range(N):
            x,y,h = xyh[i]
            if h != 0:
                if H == 0:
                    H = h+abs(cx-x)+abs(cy-y)
                else:
                    ok = H==h+abs(cx-x)+abs(cy-y)
            else:
                ok = abs(cx-x)+abs(cy-y)-H>=0
            if not ok:
                break
        if ok:
            break
    if ok:
        break
    
print('{} {} {}'.format(cx,cy,H))

Submission status: Accepted

Solution code:
N = int(input())

A = []
for i in range(N):
    x,y,h = map(int, input().split())
    A.append([x,y,h])
H = max([h for x,y,h in A])
while True:
    for i in range(100+1):
        for j in range(100+1):
            for x,y,h in A:
                tx, ty = abs(x-i), abs(y-j)
                if max(H - tx - ty, 0) != h:
                    break
            else:
                print(i,j,H)
                exit()
    H += 1

Submission status: Accepted

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

for i in range(N):
    if h[i] > 0:
        xx = x[i]
        yy = y[i]
        hh = h[i]

for cx in range(101):
    for cy in range(101):
        H = hh + abs(xx - cx) + abs(yy - cy)
        ok = True
        for i in range(N):
            if h[i] != max(H-abs(x[i] - cx) - abs(y[i] - cy), 0):
                ok = False
        if ok:
            print(cx, cy, H)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
x = [0 for i in range(N)]
y = [0 for i in range(N)]
h = [0 for i in range(N)]

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

ans = 0
ans_cx = 0
ans_cy = 0
for cx in range(0, 101):
    for cy in range(0, 101):
        for i in range(N):
            if h[i] != 0:
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
                break
        
        can_be_ans = True
        for i in range(N):
            if h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0):
                can_be_ans = False
                break

        if can_be_ans:
            if ans < H:
                ans = H
                ans_cx = cx
                ans_cy = cy

print(ans_cx, ans_cy, ans)

Submission status: Accepted

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

zahyo.sort(key=lambda x:x[2], reverse = 1)
mx,my,mh=zahyo[0]
for Cx in range(101):
    for Cy in range(101):
        H = mh+abs(mx-Cx)+abs(my-Cy)
        if all(h == max(H-abs(x-Cx)-abs(y-Cy),0) for x,y,h in zahyo):
            print(Cx,Cy,H)
            break

Submission status: Accepted

Solution code:
n = int(input())

x = []
y = []
h = []

for i in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])

for i in range(n):
    if h[i] >= 1:
        t = i
        break

for cy in range(101):
    for cx in range(101):
        H = h[t] + abs(x[t] - cx) + abs(y[t] - cy)
        for i in range(n):
            if h[i] != max(H - abs(cx - x[i]) - abs(cy - y[i]), 0):
                break
            if i == n - 1:
                print('{} {} {} '.format(cx, cy, H))

Submission status: Accepted

Solution code:
N = int(input())
hint_array = [list(map(int, input().split())) for i in range(N)]
hint_array = sorted(hint_array, key=lambda x: -x[2])
can_center_array = [[0] * 101 for i in range(101)]

x, y, h = hint_array[0]
for i in range(101):
    for j in range(101):
        can_center_array[i][j] = h + abs(i - x) + abs(j - y)
# print(can_center_array)
# exit()
for hint in hint_array[1:]:
    x, y, h = hint
    # print(x,y,h,"hoge")
    ans_x = 0
    ans_y = 0
    ans_h = 0
    can_put_num = 0
    for i in range(101):
        for j in range(101):
            if can_center_array[i][j] == 0:
                continue
            if can_center_array[i][j] == (h + abs(i - x) + abs(j - y)):
                can_put_num += 1
                if can_put_num == 1:
                    ans_x = i
                    ans_y = j
                    ans_h = can_center_array[i][j]
            else:
                can_center_array[i][j] = 0
    if can_put_num == 1:
        print(ans_x, ans_y, ans_h)
        exit()

Submission status: Accepted

Solution code:
import numpy as np
from functools import reduce

def dist(array,xyh):
    return (abs(array.real-xyh[0])+abs(array.imag-xyh[1])+xyh[2])

def dist2(array,xyh,dxyh):
    if xyh[2]>0:
        return dist(array,xyh) == dxyh
    else:
        return dist(array,xyh) >= dxyh

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

a=np.arange(101)+np.arange(101).reshape(101,1)*1j
dxyh=dist(a,xyh[0])

ans=np.where(reduce(lambda a,b:a&b,[dist2(a,xyh[i],dxyh) for i in range(1,N)]) == True)
print(ans[1][0],ans[0][0],int(dxyh[ans[0][0],ans[1][0]]))

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    conds = [list(map(int, input().split(" "))) for i in range(N)]
    
    first = sorted(conds, reverse=True, key=lambda x:x[2])[0]
    for cx in range(101):
        for cy in range(101):
            H = abs(first[0]-cx)+abs(first[1]-cy)+first[2]
            for n in range(N):
                cond = conds[n]
                if cond[2] == 0:
                    if abs(cond[0]-cx)+abs(cond[1]-cy) < H: 
                        break
                elif abs(cond[0]-cx)+abs(cond[1]-cy)+cond[2] != H:
                    break
            else:
                print("{} {} {}".format(cx, cy, H))
                exit()


if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
N = int(input())
XYH = [list(map(int,input().split())) for i in range(N)]
XYH.sort(key = lambda x:x[2], reverse = 1)
mx,my,mh = XYH[0]
for Cx in range(101):
    for Cy in range(101):
        H = mh+abs(mx-Cx)+abs(my-Cy)
        if all(h == max(H-abs(X-Cx)-abs(Y-Cy),0) for X,Y,h in XYH):
            print(Cx,Cy,H)
            break

Submission status: Accepted

Solution code:
N = int(input())
XYH = [list(map(int,input().split())) for i in range(N)]
XYH.sort(key = lambda x:x[2], reverse = 1)
for Cx in range(101):
    for Cy in range(101):
        H = XYH[0][2]+abs(XYH[0][0]-Cx)+abs(XYH[0][1]-Cy)
        cnt = 0
        for X,Y,h in XYH:
            if h == max(H-abs(X-Cx)-abs(Y-Cy),0):
                    cnt += 1
        if cnt == N:
            print(Cx,Cy,H)
            break

Submission status: Accepted

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

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

H0 = xyh[-1][2]

for H in range(H0,H0+200):
    for CX in range(101):
        for CY in range(101):
            for n in range(N):
                if max(0, H-abs(xyh[n][0]-CX)-abs(xyh[n][1]-CY)) != xyh[n][2]:
                    break
            else:
                print(CX, CY, H)
                break
        else:
            continue
        break
    else:
        continue
    break

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
inl = [LI() for i in range(N)]
inl.sort(key=lambda x: x[2], reverse=True)

st=set()
prevset=set()
for x,y,h in inl:
    st = set()
    for i in range(101):
        for j in range(101):
            abso = abs(x-i)+abs(y-j)
            if not h == 0:
                st.add((i,j, h+abso))
            else:
                for k in range(1, abso+1):
                    st.add((i,j, k))

    prevset = st if not prevset else st.intersection(prevset)
    if len(prevset) == 1:
        break

print(*prevset.pop())

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()



inl = [LI() for i in range(N)]
inl.sort(key=lambda x: x[2], reverse=True)

st=set()
prevset=set()
for x,y,h in inl:
    st = set()
    for i in range(101):
        for j in range(101):
            abso = abs(x-i)+abs(y-j)
            if not h == 0:
                st.add((i,j, h+abso))
            else:
                for k in range(1, abso+1):
                    st.add((i,j, k))

    prevset = st if not prevset else st.intersection(prevset)
    if len(prevset) == 1:
        break

print(*prevset.pop())

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
X, Y, H = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

H = np.array(H)
X = np.array(X)
Y = np.array(Y)
base_i = np.where(H > 0)[0][0]

ans = []
for cx in range(101):
    for cy in range(101):
        ch = abs(X[base_i] - cx) + abs(Y[base_i] - cy) + H[base_i]
        ok = True
        for x, y, h in zip(X, Y, H):
            if h > 0 and ch != abs(x - cx) + abs(y - cy) + h:
                ok = False
                break
            if h == 0 and ch > abs(x - cx) + abs(y - cy):
                ok = False
                break
        if ok:
            ans = cx, cy, ch
print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i
        
for cx in range(101):
    for cy in range(101):

        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            print(cx,cy,h)
            break

Submission status: Accepted

Solution code:
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i

dct = 0
for cx in range(101):
    for cy in range(101):
        if dct:
            break
        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            print(cx,cy,h)

Submission status: Accepted

Solution code:
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i
        
Cx,Cy,H = -1,-1,-1
        
for cx in range(101):
    for cy in range(101):
        if H >= 0:
            break
        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            Cx,Cy,H = cx,cy,h

print(Cx,Cy,H)

Submission status: Accepted

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

xyh_hNonzero = sorted(xyh, reverse=True, key=lambda x:x[2])[0]

for cx in range(101):
  for cy in range(101):
    h = abs(xyh_hNonzero[0] - cx) + abs(xyh_hNonzero[1] - cy) + xyh_hNonzero[2]
    for i in range(N):
      if xyh[i][2] == 0:
        if abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) < h:
          break
      elif abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) + xyh[i][2] != h:
        break
    else:
      print(' '.join(map(str, [cx,cy,h])))
      exit()
else:
  raise Exception('aaa!!!')

Submission status: Accepted

Solution code:
N = int(input())
d = []
for j in range(N):
    X, Y, H = map(int,input().split())
    d.append([X, Y, H])
    if H != 0:
        a = [X, Y, H]
for x in range(101):
    for y in range(101):
        flag = True
        h = a[2] + abs(a[0] - x) + abs(a[1] - y)
        for i in d:
            if i[2] != max(h - abs(i[0] - x) - abs(i[1] - y), 0):
                flag = False
                break

        if flag:
            print(x, y, h)
            exit()

Submission status: Accepted

Solution code:
n = int(input())
lis = [list(map(int,input().split())) for x in range(n)]
lis = sorted(lis,key=lambda x:x[2])

bx,by,bh = -1,-1,-1
for cy in range(101):
    for cx in range(101):
        if bh >= 0:break
        #1点決めて基準の高さ(？)を決めておく
        h = abs(lis[-1][0] - cx) + abs(lis[-1][1] - cy) + lis[-1][2]	
        ok = True
        for li in lis:
            #もし高さがすべて確かに一致したときok
            if max(h - abs(li[0]-cx) - abs(li[1]-cy),0) != li[2]:
                ok = False
                break
        if ok :
            bx,by,bh = cx,cy,h
print(bx,by,bh)

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())


#[0], [1], [2]にx, y, hがそれぞれ入る
inf = [list(mi()) for _ in range(N)]

from copy import deepcopy
#ht>=1である情報を1つピックアップ
#ex(example) にその情報を入れる
for eachinf in inf:
  if eachinf[2] >= 1:
    ex = deepcopy(eachinf)
    break

import itertools
#まずpx,pyを決める（productで自動的に決まっている）
for px, py in itertools.product(range(101), repeat=2):
  #px,pyが決まったので、次はその場合のHを求める
  ph = ex[2] + abs(ex[0] - px) + abs(ex[1] - py)
  isrightans = 1
  for x, y, h in inf:
    if h != max(ph - abs(x - px) - abs(y - py),0):
      isrightans = 0
      break
  if isrightans:
    print(px, py, ph)
    exit()

Submission status: Accepted

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

ans = ''
for i in range(101):
    for j in range(101):
        m = 1000000001

        for k in range(n):
            x = abs(l[k][0] - i)
            y = abs(l[k][1] - j)

            if x + y < m:
                m = x + y
                hhh = l[k][2] + x + y

        b = True
        for k in range(n):
            x = abs(l[k][0] - i)
            y = abs(l[k][1] - j)

            if l[k][2] != 0 and x + y + l[k][2] != hhh:
                b = False
                break

        if b:
            ans = str(i) + ' ' + str(j) + ' ' + str(hhh)

print(ans)

Submission status: Accepted

Solution code:
l=[list(map(int,input().split())) for i in range(int(input()))]
l.sort(key=lambda x:x[2])
for i in range(0,101):
    for j in range(0,101):
        h=l[-1][2]+abs(i-l[-1][0])+abs(j-l[-1][1])
        for a,b,c in l[:-1]:
            if c!=max(0,h-abs(i-a)-abs(j-b)):break
        else:
            print(i,j,h)
            exit()

Submission status: Accepted

Solution code:
N = int(input())
xyh = sorted([list(map(int,input().split())) for _ in range(N)], key = lambda x: -x[2])
for Cx in range(101):
  mx, my, mh = xyh[0]
  for Cy in range(101):
    H = mh + abs(mx - Cx) + abs(my - 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: Accepted

Solution code:
n=int(input())
l=[[]]*n
for i in range(n):
    l[i]=list(map(int,input().split()))
lst=sorted(l,key=lambda x:-x[2])
flag=False

for i in range(0,101):#i=X
    if flag:
        break
    for j in range(0,101):#j=Y
        if flag:
            break
        tmp=lst[0][2]+abs(lst[0][0]-i)+abs(lst[0][1]-j)
        for k in range(n):
            if lst[k][2]!=0:
            #print(k,'ループ目')
                sum=abs(lst[k][0]-i)+abs(lst[k][1]-j)
                H=lst[k][2]+sum
                if tmp!=H :
                    break
                a,b,c=i,j,H
                if k==n-1:
                    flag=True
                    print(i,j,H,)
                    break
            
            else:
                
                if lst[k][2]!=max(c-abs(a-lst[k][0])-abs(b-lst[k][1]),0):
                    #print(c,abs(a-lst[k][0]),abs(b-lst[k][1]))
                    break
                if k==n-1:
                    flag=True
                    print(i,j,H)
                    break

Submission status: Accepted

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

for cy in range(101):
	for cx in range(101):
		ch = None
		for x, y, h in XYH:
			if 0 == h:
				continue
			dy, dx = abs(y - cy), abs(x - cx)
			ch = h + dy + dx
		if all([h == max(0, ch - abs(y - cy) - abs(x - cx)) for x, y, h in XYH]):
			print(cx, cy, ch)
			exit()

Submission status: Accepted

Solution code:
from sys import exit, stdin
N = int(stdin.readline().rstrip())
XYH = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
for x, y, h in XYH:
    for cx in range(101):
        for cy in range(101):
            if h == 0:
                continue
            else:
                H = h + abs(cx-x) + abs(cy-y)
                if all([th == max(H-abs(cx-tx)-abs(cy-ty), 0) for tx, ty, th in XYH]):
                    print(cx, cy, H)
                    exit()

Submission status: Accepted

Solution code:
N = int(input())
cod = []
rx, ry, rh = 0, 0, 0
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        rx, ry, rh = x, y, h
    cod.append([x, y, h])

for i in range(101):
    for j in range(101):
        H = rh+abs(rx-i)+abs(ry-j)
        flg = True
        for x, y, h in cod:
            if max(H - abs(x-i) - abs(y-j), 0) != h:
                flg = False
                break
        if flg:
            print(i, j, H)
            quit()

Submission status: Accepted

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

for x,y,h in lst:
    if h != 0:
        break

for cx in range(101):
    for cy in range(101):
        H = abs(cx-x) + abs(cy-y) + h
        if all(hi == max(H-abs(cx-xi)-abs(cy-yi),0) for xi,yi,hi in lst):
            print(cx,cy,H)
            exit()

Submission status: Accepted

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

minH = 0
for xyh in xyhs:
  minH = max(minH, xyh[2])

cx, cy, H = 0, 0, 0
for h in range(minH, minH+200):
  if H != 0: break
  for x in range(101):
    if H != 0: break
    for y in range(101):
      if H != 0: break
      for xyh in xyhs:
        if max(h - abs(xyh[0]-x) - abs(xyh[1]-y), 0) != xyh[2]:
          break
      else:
        cx, cy, H = x, y, h
        break

print(cx, cy, H)

Submission status: Accepted

Solution code:
import sys

N = int(input())
pyramid = []

for _ in range(N):
    pyramid.append(list(map(int,input().split())))

# 総当たり
for cx in range(101):
    for cy in range(101):
        H = []
        for k in range(N):
            if pyramid[k][2] != 0:
                H.append(abs(pyramid[k][0]-cx) + abs(pyramid[k][1]-cy) + pyramid[k][2])
        if len(set(H)) == 1:
            for k in range(N):
                if pyramid[k][2] != max(H[0]-abs(pyramid[k][0]-cx)-abs(pyramid[k][1]-cy),0):
                    break
            if k == N-1:
                print(cx,cy,H[0])
                sys.exit()

Submission status: Accepted

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

for x, y, h in l:
    if h != 0:
        break

for Cx in range(0, 101):
    for Cy in range(0, 101):
        H = abs(Cx-x) + abs(Cy-y) + h
        if all(hh == max(H - abs(Cx-xx) - abs(Cy-yy), 0) for xx, yy, hh in l):
            print(Cx, Cy, H)
            exit()

Submission status: Accepted

Solution code:
n = int(input())

x = [0] * n
y = [0] * n
h = [0] * n

for i in range(n):
    x[i],y[i],h[i] = map(int,input().split())
    
ans_x = 0 
ans_y = 0  
ans_h = 0

for i in range(101):
    for j in range(101):
        H_candidate = []
        for k in range(n):
            if h[k] != 0:
                H_candidate.append(abs(x[k]-i)+abs(y[k]-j)+h[k])
        if len(set(H_candidate)) == 1:
            flag = True
            for k in range(n):
                if h[k] != max(H_candidate[0]-abs(x[k]-i)-abs(y[k]-j),0):
                    flag = False
            if flag:
                ans_x = i
                ans_y = j
                ans_h = H_candidate[0]
print(ans_x,ans_y,ans_h)

Submission status: Accepted

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

for x, y, h in l:
    if h == 0:
        continue
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = abs(Cx-x) + abs(Cy-y) + h
            if all(hh == max(H - abs(Cx-xx) - abs(Cy-yy), 0) for xx, yy, hh in l):
                print(Cx, Cy, H)
                exit()

Submission status: Accepted

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

for x, y, h in l:
    if h == 0:
        continue
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = abs(Cx-x) + abs(Cy-y) + h
            if all([hh == max(H - abs(Cx-xx) - abs(Cy-yy), 0) for xx, yy, hh in l]):
                print(Cx, Cy, H)
                exit()

Submission status: Accepted

Solution code:
from collections import defaultdict

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

for x, y, h in l:
    if h == 0:
        continue
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = abs(Cx-x) + abs(Cy-y) + h
            if all([hh == max(H - abs(Cx-xx) - abs(Cy-yy), 0) for xx, yy, hh in l]):
                print(Cx, Cy, H)
                exit()

Submission status: Accepted

Solution code:
from collections import defaultdict

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

for x, y, h in l:
    if h == 0:
        continue
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            ans = True
            H = abs(Cx-x) + abs(Cy-y) + h
            for xx, yy, hh in l:
                if hh != max(H - abs(Cx-xx) - abs(Cy-yy), 0):
                    ans = False
            if ans:
              print(Cx, Cy, H)
              exit()

Submission status: Accepted

Solution code:
n=int(input())
X=[list(map(int,input().split())) for _ in range(n)]
X.sort(key=lambda x:x[2])
a,b,c=X[-1]
for px in range(101):
    for py in range(101):
        H=abs(px-a)+abs(py-b)+c
        if all(h==max(H-abs(x-px)-abs(y-py),0) for x,y,h in X):
            print(px,py,H)
            break