Language: C++


#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
    //int i,j,k,l,r,x,y; string s;
    int i;
    bool exit = false;
    int N;
    cin>>N;
    vector <int> x,y;
    vector <ll> h;
    FOR(i,N){
        ll input;
        cin>>input;
        x.push_back(input);
        cin>>input;
        y.push_back(input);
        cin>>input;
        h.push_back(input);
    }
    int Cx,Cy,retX=-1,retY=-1;
    ll H;
    FOR(Cx,101){
        FOR(Cy,101){
            exit=false;
            FOR(i,N){
                if(i==0) continue;
                if(max((abs(Cx-x[0])+abs(Cy-y[0])+h[0])-(abs(Cx-x[i])+abs(Cy-y[i])),0)  != h[i] ){
                    //cout<<Cx<<" "<<Cy<<" "<<i<<endl;
                    exit=true;
                    break;
                }
            }
            if(exit==false){
                //cout<<Cx<<Cy<<endl;
                retX=Cx;
                retY=Cy;
            }
        }
    }
    cout<<retX<<" "<<retY<<" "<<abs(retX-x[0])+abs(retY-y[0]) + h[0]<<endl;
    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



Compiler output:
a.cc: In function 'void solve()':
a.cc:41:23: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, int)'
   41 |                 if(max((abs(Cx-x[0])+abs(Cy-y[0])+h[0])-(abs(Cx-x[i])+abs(Cy-y[i])),0)  != h[i] ){
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:41:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   41 |                 if(max((abs(Cx-x[0])+abs(Cy-y[0])+h[0])-(abs(Cx-x[i])+abs(Cy-y[i])),0)  != h[i] ){
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:41:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   41 |                 if(max((abs(Cx-x[0])+abs(Cy-y[0])+h[0])-(abs(Cx-x[i])+abs(Cy-y[i])),0)  != h[i] ){
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~