Problem: 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.

Submission attempts (in order):
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']

# 1 2	| x,y = s_inpl()   |	x=1,y=2




# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())


import math
import copy
from collections import defaultdict, Counter

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
x, y, h = [], [], []
for _ in range(N):
    xi, yi, hi = s_inpl()
    x.append(xi)
    y.append(yi)
    h.append(hi)


MAX = 100;

for pos_y in range(MAX+1):
    for pos_x in range(MAX+1):
        
        need_h = -1
        
        for i in range(N):
            if h[i] > 0:
                
                
                tmp_h = h[i] + abs(pos_y-y[i]) + abs(pos_x-x[i])
                if need_h == -1:
                    need_h = tmp_h
                else:
                    if need_h != tmp_h:
                        need_h = -2
                        break
        
        if need_h == -2:
            continue

        
        
        for i in range(N):
            if h[i] == 0:
                dist = abs(pos_y - y[i]) + abs(pos_x - pos_x)
                if need_h > dist:
                    need_h = -2

        if need_h == -2:
            continue

        break
print("{} {} {}".format(pos_x, pos_y, need_h))



# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']

# 1 2	| x,y = s_inpl()   |	x=1,y=2




# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())


import math
import copy
from collections import defaultdict, Counter

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
x, y, h = [], [], []
for _ in range(N):
    xi, yi, hi = s_inpl()
    x.append(xi)
    y.append(yi)
    h.append(hi)


MAX = 100;

ans_x, ans_y, ans_h = -1, -1, -1
for pos_y in range(MAX+1):
    for pos_x in range(MAX+1):
        
        need_h = -1
        
        for i in range(N):
            if h[i] > 0:
                
                
                tmp_h = h[i] + abs(pos_y-y[i]) + abs(pos_x-x[i])
                if need_h == -1:
                    need_h = tmp_h
                else:
                    if need_h != tmp_h:
                        need_h = -2
                        break
        
        if need_h == -2:
            continue

        
        
        for i in range(N):
            if h[i] == 0:
                dist = abs(pos_y - y[i]) + abs(pos_x - x[i])
                if need_h > dist:
                    need_h = -2

        if need_h == -2:
            continue
        ans_x, ans_y, ans_h = pos_x, pos_y, need_h

print("{} {} {}".format(ans_x, ans_y, ans_h))



Verdicts: Wrong Answer

Accepted