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())
xyh = [list(map(int, input().split())) for i in range(N)]
# print(N, xyh)

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = 0
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break

        found = True
        for x, y, h in xyh:
            # if h == 0: continue
            # if h + abs(x - cx) + abs(y - cy) != candidate:
            if candidate - abs(x - cx) - abs(y - cy) - h >= 0:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = 0
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break

        found = True
        for x, y, h in xyh:
            # if h == 0: continue
            # if h + abs(x - cx) + abs(y - cy) != candidate:
            if candidate - abs(x - cx) - abs(y - cy) - h > 0:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = 0
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break

        found = True
        for x, y, h in xyh:
            # if h == 0: continue
            # if h + abs(x - cx) + abs(y - cy) != candidate:
            if candidate - abs(x - cx) - abs(y - cy) - h <= 0:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = 0
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break
        
        found = True
        for x, y, h in xyh:
            if h == 0: continue
            if h + abs(x - cx) + abs(y - cy) != candidate:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = None
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break
        
        found = True
        for x, y, h in xyh:
            if h == 0: continue
            if h + abs(x - cx) + abs(y - cy) != candidate:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        found = True

        candidate = None
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break
        if candidate is None:
            found = True
            candidate = 0
            
        for x, y, h in xyh:
            if h == 0: continue
            if h + abs(x - cx) + abs(y - cy) != candidate:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate

print(cx, cy, height)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = None
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break
        
        found = True
        for x, y, h in xyh:
            if h == 0: continue
            if h + abs(x - cx) + abs(y - cy) != candidate:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, candidate)

Submission status: Wrong Answer

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

height = None
found = False
candidate = 0
for cx in range(0, 101):
    for cy in range(0, 101):
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break
        
        found = True
        for x, y, h in xyh:
            if h == 0: continue
            if h + abs(x - cx) + abs(y - cy) != candidate:
                found = False
                break
        
        if found is True: break
    if found is True: break

print(cx, cy, candidate)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = None
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break
        
        found = True
        for x, y, h in xyh:
            if h == 0: continue
            if h + abs(x - cx) + abs(y - cy) != candidate:
                found = False
                break
        
        if found is True: break
    if found is True: break

print(cx, cy, candidate)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        # height = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
        # foo = []
        # for x, y, h in xyh:
        #     foo.append(abs(x - cx) + abs(y - cy) + h == max(0, height))
        # found = all(foo)

        non_zero = None
        found = True
        for x, y, h, in xyh:
            height = abs(x - cx) + abs(y - cy) + h
            if height == 0: continue
            else:
                if non_zero is None:
                    non_zero = height
                elif non_zero != height:
                    found = False
                    break


        if found: break
    if found: break
print(cx, cy, height)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        height = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
        foo = []
        for x, y, h in xyh:
            if height == 0:
                foo.append(True)
                continue
            foo.append(abs(x - cx) + abs(y - cy) + h == max(0, height))
        found = all(foo)

        if found: break
    if found: break
print(cx, cy, height)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        height = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
        foo = []
        for x, y, h in xyh:
            foo.append(abs(x - cx) + abs(y - cy) + h == max(0, height))
        found = all(foo)

        if found: break
    if found: break
print(cx, cy, height)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        height = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
        foo = [abs(x - cx) + abs(y - cy) + h == max(0, height) for x, y, h in xyh]
        found = all(foo)
        if found: break
    if found: break
print(cx, cy, height)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        height = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
        foo = [(abs(x - cx) + abs(y - cy) + h == height or abs(x - cx) + abs(y - cy) + h == 0) for x, y, h in xyh]
        found = all(foo)
        if found: break
    if found: break
print(cx, cy, height)

Submission status: Wrong Answer

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        height = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
        foo = [(abs(x - cx) + abs(y - cy) + h == height) for x, y, h in xyh]
        found = all(foo)
        if found: break
    if found: break
print(cx, cy, height)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
xyh = [list(map(int, readline().split())) for _ in range(n)]
xyh.sort(key=lambda x: -x[2])
for dx in range(101):
    for dy in range(101):
        flag = True
        check = abs(xyh[0][0] - dx) + abs(xyh[0][1] - dy) + xyh[0][2]
        for x, y, h in xyh:
            dh = abs(x - dx) + abs(y - dy) + h
            if check != dh:
                flag = False
                break
        if flag and check > 0:
            print(dx, dy, check)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
xyh = [list(map(int, readline().split())) for _ in range(n)]
for dx in range(101):
    for dy in range(101):
        flag = True
        check = abs(xyh[0][0] - dx) + abs(xyh[0][1] - dy) + xyh[0][2]
        if check <= 0:
            continue
        for x, y, h in xyh:
            dh = abs(x - dx) + abs(y - dy) + h
            if check != dh:
                flag = False
                break
        if flag:
            print(dx, dy, check)
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
pointandheight=[list(map(int,input().split())) for _ in range(N)]
flag=0
mi=10000

for cx in range(0,101):
    for cy in range(0,101):
        buf=[0]*N
        for k in range(N):
            buf[k]=pointandheight[k][2]+abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1])
            if pointandheight[k][2]==0:
                mi=min(mi,abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1]))
            #print(pointandheight[k][2]+abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1]))
        buf.sort()
        if (buf[0]==buf[N-1]):
            ans=[cx,cy,buf[0]]
            flag=1
            break
        else:
            l=[]
            for k in range(N):
                if pointandheight[k][2]!=0:
                    l.append(pointandheight[k][2]+abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1]))
            l.sort()
            if (l[0]==l[len(l)-1])and(l[0]<=mi):
                ans=[cx,cy,l[0]]
                flag=1
                break
        #print(cx,cy,buf)
        #input()
    if flag==1:
        break
if flag==1:
    print(*ans, sep=" ")

Submission status: Wrong Answer

Solution code:
N=int(input())
pointandheight=[list(map(int,input().split())) for _ in range(N)]
flag=0
mi=10000

for cx in range(0,101):
    for cy in range(0,101):
        buf=[0]*N
        for k in range(N):
            buf[k]=pointandheight[k][2]+abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1])
            if pointandheight[k][2]==0:
                mi=min(mi,abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1]))
            #print(pointandheight[k][2]+abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1]))
        buf.sort()
        if (buf[0]==buf[N-1]):
            ans=[cx,cy,buf[0]]
            flag=1
            break
        else:
            l=[]
            for k in range(N):
                if pointandheight[k][2]!=0:
                    l.append(abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1]))
            l.sort()
            if (l[0]==l[len(l)-1])and(l[0]<=mi):
                ans=[cx,cy,l[0]]
                flag=1
                break
        #print(cx,cy,buf)
        #input()
    if flag==1:
        break
if flag==1:
    print(*ans, sep=" ")

Submission status: Wrong Answer

Solution code:
N=int(input())
pointandheight=[list(map(int,input().split())) for _ in range(N)]
flag=0
#まずH=0の時のみを調べる
for cx in range(0,101):
    for cy in range(0,101):
        buf=[0]*N
        for k in range(N):
            buf[k]=pointandheight[k][2]+abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1])
            #print(pointandheight[k][2]+abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1]))
        buf.sort()
        if (buf[0]==buf[N-1]):
            ans=[cx,cy,buf[0]]
            flag=1
            break
        elif (buf[0]<0)and(buf[N-1]<=0):
            ans=[cx,cy,0]
            flag=1
            break
        #print(cx,cy,buf)
        #input()
    if flag==1:
        break
if flag==1:
    print(*ans, sep=" ")

Submission status: Wrong Answer

Solution code:
N=int(input())
pointandheight=[list(map(int,input().split())) for _ in range(N)]
flag=0
#まずH=0の時のみを調べる
for cx in range(0,101):
    for cy in range(0,101):
        buf=[0]*N
        for k in range(N):
            buf[k]=pointandheight[k][2]+abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1])
            #print(pointandheight[k][2]+abs(cx-pointandheight[k][0])+abs(cy-pointandheight[k][1]))
        buf.sort()
        if (buf[0]==buf[N-1]):
            ans=[cx,cy,buf[0]]
            flag=1
            break
        elif (buf[0]<0)and(buf[N-1]==0):
            ans=[cx,cy,0]
            flag=1
            break
        #print(cx,cy,buf)
        #input()
    if flag==1:
        break
if flag==1:
    print(*ans, sep=" ")

Submission status: Wrong Answer

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

def main():
    N  = int(input())
    points = [input() for i in range(N)]

    T = -10000000

    for x in range(101):
        for y in range(101):
            for i,p in enumerate(points):
                p = [int(j) for j in p.split()]
                distance = abs(x-p[0]) + abs(y-p[1]) + p[2]
                if p[2] == 0:
                    if i == N-1:
                        print(x, y , T)
                        return
                    else:
                        continue

                if T==-10000000:
                    T=distance
                elif T == distance:
                    if i == N-1:
                        print(x, y , T)
                        return
                    continue
                else:
                    T =-10000000
                    break

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def main():
    N  = int(input())
    points = [input() for i in range(N)]

    T = -10000000

    for x in range(101):
        for y in range(101):
            for i,p in enumerate(points):
                p = [int(j) for j in p.split()]
                distance = abs(x-p[0]) + abs(y-p[1]) + p[2]
                if p[2] == 0:
                    if i == N-1:
                        print(x, y , T)
                        return
                    else:
                        continue                    


                if T==-10000000:
                    T=distance
                elif T == distance:
                    if i == N-1:
                        print(x, y , T)
                        return
                    continue
                else:
                    T = -1
                    break

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def main():
    N  = int(input())
    points = [input() for i in range(N)]

    T = -1

    for x in range(101):
        for y in range(101):
            for i,p in enumerate(points):
                p = [int(j) for j in p.split()]
                distance = abs(x-p[0]) + abs(y-p[1]) + p[2]
                if T==-1:
                    T=distance
                elif T == distance:
                    if i == N-1:
                        print(x, y , T)
                        return
                    continue
                else:
                    T = -1
                    break

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
x,y,h=[0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int,input().split())
mn_h=min(h)
mx_h=max(h)
for C_x in range(101):
  for C_y in range(101):
    for i in range(n):
      H=h[i]+abs(x[i]-C_x)-abs(y[i]-C_y)
      if H>0:
        if all(max(H-abs(x[j]-C_x)-abs(y[j]-C_y),0)==h[j] for j in range(n)):
          print(C_x,C_y,H)
          exit()

Submission status: Wrong Answer

Solution code:
import sys

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


def find_height(cx, cy):
    upperbound = 10 ** 12
    summit = None
    for x, y, h in obs:
        s = h + abs(cx - x) + abs(cy - y)
        if s < lowerbound:
            return None
        if h == 0:
            upperbound = min(upperbound, s)
        elif summit is None:
            summit = s
        elif summit > upperbound:
            return None
        elif summit != s:
            return None
    return summit


for cx in range(0, 101):
    for cy in range(0, 101):
        ch = find_height(cx, cy)
        if ch is not None:
            print(cx, cy, ch)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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


def find_height(cx, cy):
    required_summit = maxh
    summit = None
    for x, y, h in obs:
        s = h + abs(cx - x) + abs(cy - y)
        if s < required_summit:
            return None
        if h == 0:
            required_summit = max(required_summit, s)
        elif summit is None:
            summit = s
        elif summit != s:
            return None
    return summit


for cx in range(0, 101):
    for cy in range(0, 101):
        ch = find_height(cx, cy)
        if ch is not None:
            print(cx, cy, ch)
            sys.exit()

Submission status: Wrong Answer

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

def f(cx,cy,xi,yi,hi):
  return hi + abs(cx-xi) +abs(cy-yi)
hlist = [[None for i in range(101)] for j in range(101)]

def h_update(hlist1,i,j,hnew):
  if hlist1[i][j] == None:
    hlist1[i][j] = hnew
  elif hlist[i][j] == hnew:
    pass
  else:
    hlist1[i][j] = "aaa"
    
for x in list1:
  for i,j in itertools.product(range(101),repeat=2):
    h1 = f(i,j,x[0],x[1],x[2])
    if h1<0:
      pass
    else:
      h_update(hlist,i,j,h1)

for i,j in itertools.product(range(101),repeat=2):
  if hlist[i][j] != "aaa":
    print(i,j,hlist[i][j])

Submission status: Wrong Answer

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

def f(cx,cy,xi,yi,hi):
  return hi + abs(cx-xi) +abs(cy-yi)
hlist = [[None for i in range(101)] for j in range(101)]

def h_update(hlist1,i,j,hnew):
  if hlist1[i][j] == None:
    hlist1[i][j] = hnew
  elif hlist[i][j] == hnew:
    pass
  else:
    hlist1[i][j] = "aaa"
    
for x in list1:
  for i,j in itertools.product(range(101),repeat=2):
    if x[2] ==0:
      pass
    else:
      h1 = f(i,j,x[0],x[1],x[2])
      h_update(hlist,i,j,h1)

for i,j in itertools.product(range(101),repeat=2):
  if hlist[i][j] != "aaa":
    print(i,j,hlist[i][j])

Submission status: Wrong Answer

Solution code:
def main():
  N = int(input())
  xyh = [[int(_) for _ in input().split()] for __ in range(N)]
  for cx in range(0, 101):
    for cy in range(0, 101):
      H = set()
      for x, y, h in xyh:
        if h == 0:
          continue
        H.add(abs(cx - x) + abs(cy - y) + h)
      if len(H) == 1:
        ok = True
        hh = list(H)[0]
        for x, y, h in xyh:
          if h == 0:
            if max(hh - abs(cx - x) + abs(cy - y), 0) == 0:
              continue
            else:
              ok = False
        if ok:
          print(cx, cy, *H)
          break
    else:
      continue
    break
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  N = int(input())
  xyh = [[int(_) for _ in input().split()] for __ in range(N)]
  for cx in range(0, 101):
    for cy in range(0, 101):
      H = set()
      for x, y, h in xyh:
        if h == 0:
          continue
        H.add(abs(cx - x) + abs(cy - y) + h)
      if len(H) == 1:
        print(cx, cy, *H)
        break
    else:
      continue
    break
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
size = 101
n = int(input())
points = [tuple(map(int, input().split())) for _ in range(n)]
ans = (-1, -1, -1)
for i in range(size):
  for j in range(size):
    # 高いほうに持ち上げるよう試みて、整合性とれなければ却下
    max_h = None
    succ = True
    for x, y, h in points:
      # h=0の点は参考にできないためスキップ
      if h == 0:
        continue
      tmp = abs(i-x) + abs(j-y) + h
      if max_h == None:
        max_h = tmp
        continue
      else:
        if max_h != tmp:
          succ = False
          break
    # 成り立っているなかでの最高点を更新していく
    if succ:
      if ans[2] < max_h:
        ans = (i, j, max_h)
print('{} {} {}'.format(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

Solution code:
size = 101
n = int(input())
points = [tuple(map(int, input().split())) for _ in range(n)]
ans = (0, 0, 0)
for i in range(size):
  for j in range(size):
    # 高いほうに持ち上げるよう試みて、整合性とれなければ却下
    max_h = None
    succ = True
    for x, y, h in points:
      if h == 0: continue
      tmp = abs(i-x) + abs(j-y) + h
      if max_h == None:
        max_h = tmp
        continue
      else:
        if max_h != tmp:
          succ = False
          break
    # 成り立っているなかでの最高点を更新していく
    if succ:
      if ans[2] < max_h:
        ans = (i, j, max_h)
print('{} {} {}'.format(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

Solution code:
size = 101
n = int(input())
points = [tuple(map(int, input().split())) for _ in range(n)]
ans = (0, 0, 0)
for i in range(size):
  for j in range(size):
    # 高いほうに持ち上げるよう試みて、整合性とれなければ却下
    max_h = None
    succ = True
    for x, y, h in points:
      tmp = abs(i-x) + abs(j-y) + h
      if max_h == None:
        max_h = tmp
        continue
      else:
        if max_h != tmp:
          succ = False
          break
    # 成り立っているなかでの最高点を更新していく
    if succ:
      if ans[2] < max_h:
        ans = (i, j, max_h)
print('{} {} {}'.format(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

Solution code:
n = int(input())
info = []
for i in range(n):
    x,y,h = map(int,input().split())
    info.append((x,y,h))
info.sort(key=lambda x:x[2], reverse=True)

for i in range(0,101):
    for j in range(0,101):
        crt_h = info[0][2] + abs(info[0][0]-i) + abs(info[0][1]-j)
        flag = True
        for k in range(1, n):
            tar_x = info[k][0]
            tar_y = info[k][1]
            tar_h = info[k][2]
            H = tar_h + abs(tar_x - i) + abs(tar_y - j)
            if H != crt_h:
                flag = False
        if flag:
            print(i,j,crt_h)

Submission status: Wrong Answer

Solution code:
import sys

n=int(input())
P=[]
for i in range(n):
    x,y,h=map(int,input().split())
    P.append([h,x,y])
P=list(reversed(sorted(P)))
print(P)

for x in range(101):
    for y in range(101):
        flag=0
        H=P[0][0]+abs(P[0][1]-x)+abs(P[0][2]-y)
        for p in P:
            ph=p[0]
            px=p[1]
            py=p[2]
            if ph==0:
                if H-abs(px-x)-abs(py-y)>0:
                    flag=1
                    break
            else:
                if H-abs(px-x)-abs(py-y)!=ph:
                    flag=1
                    break
        if flag==1:
            continue
        else:
            print(x,y,H)
            sys.exit()

Submission status: Wrong Answer

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


for x in range(101):
  for y in range(101):
    tmp_H = XYH[0][2]+abs(XYH[0][0]-x)+abs(XYH[0][1]-y)
    A = 0
    for i in range(1,N):
      if tmp_H - abs(XYH[i][0]-x) - abs(XYH[i][1]-y) == XYH[i][2]:
        A +=1
    
    if A == N-1:
      print(x,y,tmp_H)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    H = []
    ans = 0
    X = []
    Y = []
    a = 0
    tmpx = 0
    tmpy = 0
    for _ in range(n):
        x,y,h = map(int,input().split())
        X.append(x)
        Y.append(y)
        H.append(h)
    for x in range(101):
        for y in range(101):
            flg = True
            ans = -1
            for i in range(n):
                if H[i] == 0:
                    continue
                tmp_h = H[i] + abs(x-X[i]) + abs(y-Y[i])
                if tmp_h <= abs(x-X[i]) + abs(y-Y[i]):
                    continue

                if ans < 0 and tmp_h != 0:
                    ans = tmp_h
                else:
                    if ans != tmp_h :
                        flg = False
                        break
            if ans == -1:
                flg = False
            if flg:
                if ans > a:
                    a = ans
                    tmpx = x
                    tmpy = y
    print(tmpx,tmpy,a)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    H = []
    ans = 0
    X = []
    Y = []
    for _ in range(n):
        x,y,h = map(int,input().split())
        X.append(x)
        Y.append(y)
        H.append(h)
    for x in range(101):
        for y in range(101):
            flg = True
            for i in range(n):
                if H[i] == 0:
                    continue
                tmp_h = H[i] + abs(x-X[i]) + abs(y-Y[i])
                if tmp_h <= abs(x-X[i]) + abs(y-Y[i]):
                    tmp_h = 0
                if i == 0:
                    ans = tmp_h
                else:
                    if ans != tmp_h:
                        flg = False
                        break
            if flg:
                print(x,y,ans)
                return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    H = []
    ans = 0
    X = []
    Y = []
    for _ in range(n):
        x,y,h = map(int,input().split())
        X.append(x)
        Y.append(y)
        H.append(h)
    for x in range(101):
        for y in range(101):
            flg = True
            for i in range(n):
                tmp_h = H[i] + abs(x-X[i]) + abs(y-Y[i])
                if tmp_h <= abs(x-X[i]) + abs(y-Y[i]):
                    tmp_h = 0
                if i == 0:
                    ans = tmp_h
                else:
                    if ans != tmp_h:
                        flg = False
                        break
            if flg:
                print(x,y,ans)
                return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
H = [[0] * 101 for i in range(101)]
ans = 0
X = 0
Y = 0
a = []
for i in range(n):
    x,y,h = map(int, input().split())
    for j in range(101):
        for k in range(101):
            if i == 0:
                if h == 0:H[j][k] = 0
                else:H[j][k] = h + abs(x-j) + abs(y-k)
            else:
                if H[j][k] < 0:
                    continue
                else:
                    if H[j][k] != h + abs(x-j) + abs(y-k) and H[j][k] != 0:
                        H[j][k] = -1
                    elif H[j][k] == 0:
                        H[j][k] = h + abs(x-j) + abs(y-k)

for i, tmp in enumerate(H):
    for j, xy in enumerate(tmp):
        if ans < xy:
            ans = xy
            X = i
            Y = j

print(X,Y,ans)