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)
r=sorted([list(map(int,input().split()))[::-1] for _ in range(n)])[::-1]

for i in range(100):
  for j in range(100):
    h1=r[0][0]+abs(r[0][1]-i)+abs(r[0][2]-j)
    flag=0
    for item in r[1:]:
      if item[0]>0:
        if item[0]+abs(item[1]-i)+abs(item[2]-j)!=h1:
          flag=1
          break
      else:
        if h1-abs(item[1]-i)-abs(item[2]-j)>0:
          flag=1
          break
    if flag==0:
      print(j,i,h1)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
#(x,y,h)
r=sorted([list(map(int,input().split()))[::-1] for _ in range(n)])[::-1]

for i in range(100):
  for j in range(100):
    h1=r[0][0]+abs(r[0][1]-i)+abs(r[0][2]-j)
    flag=0
    for item in r[1:]:
      if item[0]>0:
        if item[0]+abs(item[1]-i)+abs(item[2]-j)!=h1:
          flag=1
          break
    if flag==0:
      print(j,i,h1)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
#(x,y,h)
r=sorted([list(map(int,input().split()))[::-1] for _ in range(n)])[::-1]


for i in range(100):
  for j in range(100):
    h1=r[0][0]+abs(r[0][1]-i)+abs(r[0][2]-j)
    flag=0
    for item in r[1:]:
      if item[0]+abs(item[1]-i)+abs(item[2]-j)!=h1:
        flag=1
        break
    if flag==0:
      print(j,i,h1)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[]
for _ in range(n):
    x,y,h=map(int,input().split())
    xyh.append((h,x,y))
xyh.sort(reverse=True)

def pyramid(cx,cy):
    for i,tmp in enumerate(xyh):
        h,x,y=tmp
        if i==0:
            H=h+abs(x-cx)+abs(y-cy)
            continue
        if H!=h+abs(x-cx)+abs(y-cy):
            return False
    return True

def check():
    for cx in range(0, 101):
        for cy in range(0, 101):
            if pyramid(cx, cy):
                h, x, y=xyh[0]
                return cx, cy, h+abs(x-cx)+abs(y-cy)
            else:
                continue
    return -1, -1, -1

ans=check()
print(*ans, sep=" ")

Submission status: Wrong Answer

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]= [int(x) for x in input().split()]
H = 0
j = 0
while h[j]==0:
  j +=1
for cx in range(101):
  for cy in range(101):
    H = h[j]+abs(cx-x[j])+abs(cy-y[j])
    for n in range(N):
      res = h[n]+abs(cx-x[n])+abs(cy-y[n])
      if H==res or h[n]==0:
        if n==N-1:
          print(cx,cy,H)
          exit()
        continue
      else :
        break

Submission status: Wrong Answer

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]= [int(x) for x in input().split()]
H = 0
for cx in range(101):
  for cy in range(101):
    H = h[0]+abs(cx-x[0])+abs(cy-y[0])
    for n in range(N):
      res = h[n]+abs(cx-x[n])+abs(cy-y[n])
      if H==res or h[n]==0:
        if n==N-1:
          print(cx,cy,H)
          exit()
        continue
      else :
        break

Submission status: Wrong Answer

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]= [int(x) for x in input().split()]
H = 0
for cx in range(101):
  for cy in range(101):
    H = h[0]+abs(cx-x[0])+abs(cy-y[0])
    for n in range(N):
      res = h[n]+abs(cx-x[n])+abs(cy-y[n])
      if H==res:
        if n==N-1:
          print(cx,cy,H)
          exit()
        continue
      else :
        break

Submission status: Wrong Answer

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

H = 0
for i in range(101):
  for j in range(101):
    flag = 1
    for k in range(N):
      if p[k][2] > 0 and H == 0:
        H =p[k][2] + abs(p[k][0] - i) + abs(p[k][1] - j)
      elif p[k][2] > 0 and H != p[k][2] + abs(p[k][0] - i) + abs(p[k][1] - j):
        flag = 0
    if flag == 1:
      print(i,j,H)
    H = 0

Submission status: Wrong Answer

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

H = 0
for i in range(101):
  for j in range(101):
    flag = 1
    for k in range(N):
      if H == 0 and p[k][2] > 0:
        H =p[k][2] + abs(p[k][0] - i) + abs(p[k][1] - j)
      elif H != p[k][2] + abs(p[k][0] - i) + abs(p[k][1] - j):
        flag = 0
    if flag == 1:
      print(i,j,H)
    H = 0

Submission status: Wrong Answer

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

H = 0
for i in range(101):
  for j in range(101):
    flag = 1
    for k in range(N):
      if H == 0:
        H =p[k][2] + abs(p[k][0] - i) + abs(p[k][1] - j)
      elif H != p[k][2] + abs(p[k][0] - i) + abs(p[k][1] - j):
        flag = 0
    if flag == 1:
      print(i,j,H)
    H = 0

Submission status: Wrong Answer

Solution code:
N = int(input())
coordinate = []
ans = -1
for _ in range(N):
    x, y, h = map(int, input().split())
    if h == 0:
        continue
    coordinate.append([x, y, h])
N = len(coordinate)
for cx in range(101):
    for cy in range(101):
        x1, y1, h1 = coordinate[0]
        H1 = h1 + abs(cx-x1) + abs(cy-y1)
        f = 1
        if N == 1:
            f = 2
            Cx = x1
            Cy = y1
            ans = H1
            break
        for n in range(1, N):
            x, y, h = coordinate[n]
            H = h + abs(cx-x) + abs(cy-y)
            if H == H1:
                f *= 1
            else:
                f *= 0
            if f and n == N-1:
                break
        if f == 1:
            Cx = cx
            Cy = cy
            ans = H1
            break
    if f:
        break
        
print(Cx, Cy, ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
coordinate = []
ans = -1
for _ in range(N):
    x, y, h = map(int, input().split())
    if h == 0:
        continue
    coordinate.append([x, y, h])
N = len(coordinate)
for cx in range(101):
    for cy in range(101):
        x1, y1, h1 = coordinate[0]
        H1 = h1 + abs(cx-x1) + abs(cy-y1)
        f = 1
        for n in range(1, N):
            x, y, h = coordinate[n]
            H = h + abs(cx-x) + abs(cy-y)
            if H == H1:
                f *= 1
            else:
                f *= 0
            if f and n == N-1:
                break
        if f:
            Cx = cx
            Cy = cy
            ans = H1
            break
    if f:
        break
        
print(Cx, Cy, ans)

Submission status: Wrong Answer

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

for Cx in range(0,101):
    for Cy in range(0,101):
        H = 0
        for i in range(N):
            t = xyh[i]
            x = t[0]
            y = t[1]
            h = t[2]
            if h == 0:
                if H - abs(x-Cx) + abs(y-Cy) <= 0:
                    pass
                else:
                    break
            else:
                if H == 0:
                    H = h + abs(x-Cx) + abs(y-Cy)
                else:
                    if H == h + abs(x-Cx) + abs(y-Cy):
                       pass
                    else:
                       break
            if i == N-1:
                print(Cx,Cy,H)

Submission status: Wrong Answer

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

for Cx in range(0,101):
    for Cy in range(0,101):
        flag = 0
        for i in range(N):
            if flag == 0:
                t = xyh[i]
                x = t[0]
                y = t[1]
                h = t[2]
                H = h + abs(x-Cx) + abs(y-Cy)
                if H > 0:
                    flag = 1
            else:
                t = xyh[i]
                x = t[0]
                y = t[1]
                h = t[2]
                if H == h + abs(x-Cx) + abs(y-Cy):
                    pass
                else:
                    break
            if i == N-1:
                print(Cx,Cy,H)

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    xyh = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    xyh.sort(key=lambda w: w[2], reverse=True)

    for cx in range(101):
        for cy in range(101):
            th = xyh[0][2] + abs(cx - xyh[0][0]) + abs(cy - xyh[0][1])
            b = True
            for x, y, h in xyh:
                if h != th - abs(cx - x) - abs(cy - y):
                    b = False
                    break
            if b:
                print(cx, cy, th)
                exit()


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    xyh = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    xyh.sort(key=lambda x: x[2], reverse=True)

    for cx in range(101):
        for cy in range(101):
            H = xyh[0][2] - abs(cx - xyh[0][0]) - abs(cy - xyh[0][1])
            b = True
            for x, y, h in xyh:
                if h != H - abs(cx - x) - abs(cy - y):
                    b = False
                    break
            if b:
                print(cx, cy, H)
                exit()


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    xyh = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    for cx in range(101):
        for cy in range(101):
            ch = -1
            b = True
            for x, y, h in xyh:
                if h != 0:
                    if ch == -1:
                        ch = h + abs(cx - x) + abs(cy - y)
                    else:
                        if ch != h + abs(cx - x) + abs(cy - y):
                            b = False
                            break
            if b:
                print(cx, cy, ch)
                exit()


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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

for _ in range(N):
    xx,yy,hh=map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)

for n in range(N):
    if h[n]!=0:
        sample_id=n
        break

for Cx in range(101):
    for Cy in range(101):
        ass_h=abs(x[sample_id]-Cx)+abs(y[sample_id]-Cy)+h[sample_id]
        judge=True
        for k in range(N):
            ass=abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            if ass_h!=ass:
                judge=False
                break   
        if judge:
            print(Cx,Cy,ass_h)
            break    
    if judge:
        break

Submission status: Wrong Answer

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

for _ in range(N):
    xx,yy,hh=map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)

for n in range(N):
    if h[n]!=0:
        sample_id=n
        break

for Cx in range(101):
    for Cy in range(101):
        ass_h=abs(x[sample_id]-Cx)+abs(y[sample_id]-Cy)+h[sample_id]
        judge=True
        if ass_h<1:
            judge=False
            continue
        for k in range(N):
            ass=abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            if ass_h!=ass:
                judge=False
                break   
        if judge:
            print(Cx,Cy,ass_h)
            break    
    if judge:
        break

Submission status: Wrong Answer

Solution code:
"""memo:
for Cx, Cy in zip(range(0, 101), range(0, 101))
hi + abs(Xi-Cx)+abs(Yi-Cy) == hj + abs(Xj-Cx)+abs(Yj-Cy)
in All points

Complexity: O(N^2) <= 10000
"""
import sys
from itertools import product

input = sys.stdin.readline

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

for Cx, Cy in product(range(101), range(101)):
    last_H = None
    valid_flag = True
    for i, (xi, yi, hi) in enumerate(xyh_list):
        if hi == 0:
            continue
        currnt_H = hi + abs(xi - Cx) + abs(yi - Cy)
        if last_H is None:
            last_H = currnt_H
        elif last_H != currnt_H:
            valid_flag = False
            break
    if valid_flag:
        print(Cx, Cy, last_H)
        exit()
    elif last_H is None:
        last_H = hi + abs(xi - Cx) + abs(yi - Cy)
        print(Cx, Cy, last_H)

Submission status: Wrong Answer

Solution code:
"""memo:
for Cx, Cy in zip(range(0, 101), range(0, 101))
hi + abs(Xi-Cx)+abs(Yi-Cy) == hj + abs(Xj-Cx)+abs(Yj-Cy)
in All points

Complexity: O(N^2) <= 10000
"""
import sys
from itertools import product

input = sys.stdin.readline

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

for Cx, Cy in product(range(101), range(101)):
    last_H = None
    valid_flag = True
    for i, (xi, yi, hi) in enumerate(xyh_list):
        if hi == 0:
            continue
        currnt_H = hi + abs(xi - Cx) + abs(yi - Cy)
        if last_H is None:
            last_H = currnt_H
        elif last_H != currnt_H:
            valid_flag = False
            break
    if valid_flag:
        print(Cx, Cy, last_H)
        exit()

Submission status: Wrong Answer

Solution code:
"""memo:
for Cx, Cy in zip(range(0, 101), range(0, 101))
hi + abs(Xi-Cx)+abs(Yi-Cy) == hj + abs(Xj-Cx)+abs(Yj-Cy)
in All points

Complexity: O(N^2) <= 10000
"""
import sys
from itertools import product

input = sys.stdin.readline

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

for Cx, Cy in product(range(101), range(101)):
    last_H = None
    valid_flag = True
    for i, (xi, yi, hi) in enumerate(xyh_list):
        if hi == 0:
            continue
        currnt_H = hi + abs(xi - Cx) + abs(yi - Cy)
        if i == 0:
            last_H = currnt_H
        elif last_H != currnt_H:
            valid_flag = False
            break
    if valid_flag:
        print(Cx, Cy, last_H)
        exit()

Submission status: Wrong Answer

Solution code:
"""memo:
for Cx, Cy in zip(range(0, 101), range(0, 101))
	hi + abs(Xi-Cx)+abs(Yi-Cy) == hj + abs(Xj-Cx)+abs(Yj-Cy)
	in All points

Complexity: O(N^2) <= 10000
"""
import sys
from itertools import product

input = sys.stdin.readline

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

for Cx, Cy in product(range(101), range(101)):
    last_H = None
    valid_flag = True
    for i, (xi, yi, hi) in enumerate(xyh_list):
        currnt_H = hi + abs(xi - Cx) + abs(yi - Cy)
        if i == 0:
            last_H = currnt_H
        elif last_H != currnt_H:
            valid_flag = False
            break
    if valid_flag:
        print(Cx, Cy, last_H)
        exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(101):
    for cy in range(101):
        needH = -1
        for x, y, h in P:
            if needH == -1:
                needH = h + abs(x - cx) + abs(y - cy)
            else:
                if needH != h + abs(x - cx) + abs(y - cy):
                    needH = -2
                    break
        if needH == -2:
            continue

        # 高さが０の場合に矛盾してないか調べる
        for x, y, h in P:
            if h == 0:
                if needH > abs(x - cx) + abs(y - cy):
                    needH = -2
                    break
        if needH == -2:
            continue

        print(cx, cy, needH)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(101):
    for cy in range(101):
        needH = -1
        for x, y, h in P:
            if needH == -1:
                needH = h + abs(x - cx) + abs(y - cy)
            else:
                if needH != h + abs(x - cx) + abs(y - cy):
                    needH = -1
                    break
        if needH == -1:
            continue

        # 高さが０の場合に矛盾してないか調べる
        for x, y, h in P:
            if h == 0:
                if needH > abs(x - cx) + abs(y - cy):
                    needH = -1
                    break
        if needH == -1:
            continue

        print(cx, cy, needH)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(101):
    for cy in range(101):
        needH = -1
        for x, y, h in P:
            if needH == -1:
                needH = h + abs(x - cx) + abs(y - cy)
            else:
                if needH != h + abs(x - cx) + abs(y - cy):
                    needH = -1
                    break
        if needH == -1:
            continue

        # 高さが０の場合に矛盾してないか調べる
        for x, y, h in P:
            if h == 0:
                if needH > abs(x - cx) + abs(y - cy):
                    needH = -1
                    break
        if needH < 0:
            continue

        print(cx, cy, needH)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(101):
    for cy in range(101):
        needH = -1
        for x, y, h in P:
            if needH == -1:
                needH = h + abs(x - cx) + abs(y - cy)
            else:
                if needH != h + abs(x - cx) + abs(y - cy):
                    needH = -1
                    break
        if needH == -1:
            continue

        if needH < 0:
            continue

        print(cx, cy, needH)

Submission status: Wrong Answer

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

ok = True
res = []
for cx in range(101):
    for cy in range(101):
        x, y, h = data[0]
        hh = h + abs(cx - x) + abs(cy - y)
        ok = True
        for i, (x, y, h) in enumerate(data[1:]):
            if h + abs(cx - x) + abs(cy - y) != hh:
                ok = False
                continue
        if ok:
            res = [cx, cy, hh]
            break
    if ok:
        break
print(' '.join(map(str, res)))

Submission status: Wrong Answer

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

sx, sy, sh = 0, 0, 0

for _ in range(n):
    x, y, h = map(int, input().split())
    pyramid.append([x, y, h])
    if h > 0:
        sx, sy, sh = x, y, h

for cx in range(101):
    for cy in range(101):
        candidate = abs(sx-cx) + abs(sy-cy) + sh
        check = True

        for x, y, h in pyramid:
            H = abs(x-cx) + abs(y-cy) + h
            if candidate != H:
                check = False
                break

        if check:
            print(cx, cy, candidate)
            exit()

Submission status: Wrong Answer

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

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

for cx in range(101):
    for cy in range(101):
        sx, sy, sh = pyramid[0]
        preH = abs(sx-cx) + abs(sy-cy) + sh
        check = True

        for x, y, h in pyramid:
            H = abs(x-cx) + abs(y-cy) + h
            if preH != H:
                check = False
                break

        if check:
            print(cx, cy, preH)
            exit()

Submission status: Wrong Answer

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

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

for cx in range(101):
    for cy in range(101):
        sx, sy, sh = pyramid[0]
        preH = abs(sx-cx) + abs(sy-cy) + sh

        for x, y, h in pyramid:
            H = abs(x-cx) + abs(y-cy) + h
            if preH != H:
                break

        else:
            print(cx, cy, preH)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

for cx in range(101):
    for cy in range(101):
        H = xyh[0][2] + abs(xyh[0][0]-cx) + abs(xyh[0][1]-cy)
        Flag = True
        for i in range(1,N):
            tmp = xyh[i][2] + abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy)
            if (xyh[i][2] == 0 and H < tmp) or (xyh[i][2] != 0 and H != tmp):
                Flag = False
                break
        if Flag:
            print(cx,cy,H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

for cx in range(101):
    for cy in range(101):
        H = xyh[0][2] + abs(xyh[0][0]-cx) + abs(xyh[0][1]-cy)
        Flag = True
        for i in range(1,N):
            tmp = xyh[i][2] + abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy)
            if (xyh[i][2] == 0 and tmp < abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy)) or (xyh[i][2] != 0 and H != tmp):
                Flag = False
                break
        if Flag:
            print(cx,cy,H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

for cx in range(101):
    for cy in range(101):
        H = xyh[0][2] + abs(xyh[0][0]-cx) + abs(xyh[0][1]-cy)
        Flag = True
        for i in range(1,N):
            tmp = xyh[i][2] + abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy)
            if (xyh[i][2] == 0 and tmp > abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy)) or H != tmp:
                Flag = False
                break
        if Flag:
            print(cx,cy,H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

for cx in range(101):
    for cy in range(101):
        H = xyh[0][2] + abs(xyh[0][0]-cx) + abs(xyh[0][1]-cy)
        Flag = True
        for i in range(1,N):
            tmp = xyh[i][2] + abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy)
            if H != tmp:
                Flag = False
                break
        if Flag:
            print(cx,cy,H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
# 解説放送を観て写経
import sys

N = int(input())
xyh = []
for _ in range(N):
  x, y, h = map(int, input().split())
  xyh.append((x, y, h))
for i in range(101):
  for j in range(101):
    needH = -1
    for x, y, h in xyh:
      if h>0:
        tmp = h+abs(i-x)+abs(j-y)
        if needH==-1:
          needH = tmp
        else:
          if needH!=tmp:
            needH = -2
            break
          
    if needH==-2:
      continue
      
    for x, y, h in xyh:
      if h==0:
        dist = abs(i-x)+abs(j-y)
        if needH>dist:
          needH = -2
          break
          
    print(i, j, needH)
    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
xyh = []
for _ in range(N):
  x, y, h = map(int, input().split())
  xyh.append((x, y, h))
x0, y0, h0 = xyh[0]
for i in range(101):
  for j in range(101):
    H = abs(i-x0)+abs(j-y0)+h0
    flg = 1
    for x, y, h in xyh[1:]:
      if h!=max((H-abs(i-x)-abs(j-y)), 0):
        flg = 0
    if flg==1:
      print(i, j, H)
      sys.exit()

Submission status: Wrong Answer

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

def check(cx, cy):
  x, y, h = xy[0]
  ch0 = h + abs(cx - x) + abs(cy - y)
  for (x, y, h) in xy[1:]:
    ch = h + abs(cx - x) + abs(cy - y)
    if ch != ch0:
      return False
  return ch

for cx in range(101):
  for cy in range(101):
    ch = check(cx, cy)
    if ch:
      print(' '.join( map(str, [cx, cy, ch]) ))
      exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
h = [list(map(int, input().split())) for _ in range(N)]
ans = [0] * 3
for i in range(101):
    for j in range(101):
        ansB = True
        ansh = 0
        for k in range(N):
            if h[k][2] == 0:
                ansh = 0
                
            if ansh == 0:
                ansh = h[k][2] + abs(h[k][0] - i) + abs(h[k][1] - j)

            tmp = max(ansh - abs(h[k][0] - i) - abs(h[k][1] - j), 0)
            if h[k][2] != 0 and tmp != h[k][2]:
                ansB = False
                break

        if ansB:
            print(i, j, ansh)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
h = [list(map(int, input().split())) for _ in range(N)]
ans = [0] * 3
for i in range(101):
    for j in range(101):
        ansB = True
        ansh = 0
        for k in range(N):
            if h[k][2] == 0:
                continue
            if ansh == 0:
                ansh = h[k][2] + abs(h[k][0] - i) + abs(h[k][1] - j)

            tmp = max(ansh - abs(h[k][0] - i) - abs(h[k][1] - j), 0)
            if tmp != 0 and tmp != h[k][2]:
                ansB = False
                break

        if ansB:
            print(i, j, ansh)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
h = [list(map(int, input().split())) for _ in range(N)]
ans = [0] * 3
for i in range(101):
    for j in range(101):
        ansB = True
        ansh = 0
        for k in range(N):
            if h[k][2] == 0:
                continue
            if ansh == 0:
                ansh = h[k][2] + abs(h[k][0] - i) + abs(h[k][1] - j)

            tmp = max(ansh - abs(h[k][0] - i) - abs(h[k][1] - j), 0)
            if tmp != h[k][2]:
                ansB = False
                break

        if ansB:
            print(i, j, ansh)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
h = [list(map(int, input().split())) for _ in range(N)]
ans = [0] * 3
for i in range(101):
    for j in range(101):
        ansB = True
        ansh = 0
        for k in range(1, N):
            if h[k][2] == 0:
                continue
            if ansh == 0:
                ansh = h[k][2] + abs(h[k][0] - i) + abs(h[k][1] - j)

            tmp = max(ansh - abs(h[k][0] - i) - abs(h[k][1] - j), 0)
            if tmp != h[k][2]:
                ansB = False
                break

        if ansB:
            print(i, j, ansh)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
h = [list(map(int, input().split())) for _ in range(N)]
ans = [0] * 3
for i in range(101):
    for j in range(101):
        ansh = h[0][2] + abs(h[0][0] - i) + abs(h[0][1] - j)
        ansB = True
        for k in range(1, N):
            tmp = ansh - abs(h[k][0] - i) - abs(h[k][1] - j)
            if tmp != h[k][2]:
                ansB = False
                break

        if ansB:
            print(i, j, ansh)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
h = [list(map(int, input().split())) for _ in range(N)]
ans = [0] * 3
for i in range(101):
    for j in range(101):
        ansh = h[0][2] + abs(h[0][0] - i) + abs(h[0][1] - j)
        ansB = True
        for k in range(1, N):
            tmp = max(ansh - abs(h[k][0] - i) - abs(h[k][1] - j), 0)
            if tmp != h[k][2]:
                ansB = False
                break

        if ansB:
            print(i, j, ansh)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
h = [list(map(int, input().split())) for _ in range(N)]
ans = [0] * 3
for i in h:
    for j in range(101):
        for k in range(101):
            tmp = i[2] + abs(i[0] - j) + abs(i[1] - k)
            tMax = max(tmp, 0)
            if tMax > 0:
                ans[0] = j
                ans[1] = k
                ans[2] = i[2] + abs(i[0] - j) + abs(i[1] - k)
                print(ans[0], ans[1], ans[2])
                sys.exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[[int(i) for i in input().split()] for j in range(n)]

for i in range(101):
    for j in range(101):
        check=abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
        aa =0
        zero = 0
        for k in range(n):
            if xyh[k][2]==0:
                zero +=1
                continue
            if check == abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]:
                aa+=1
            else:
                break
            if aa+zero==n:
                
                ansx=i
                ansy=j
                ansh=abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
                print(ansx,ansy,ansh)
                exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[[int(i) for i in input().split()] for j in range(n)]

for i in range(201):
    for j in range(201):
        check=abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
        aa =0
        for k in range(n):
            if check == abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]:
                aa+=1
            else:
                break
            if aa==n:
                
                ansx=i
                ansy=j
                ansh=abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
                print(ansx,ansy,ansh)
                exit()