1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #include <bits/stdc++.h> #define ll long long #define ld long double #define N 10005 #define FOR(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> using namespace std; vector<pii> vec;
bool cmp(pii a,pii b){ if(a.first==b.first)return a.second>b.second; return a.first<b.first; }
int main(){ int n,x,y,h;cin>>n; for(int i=0;i<n;i++){ cin>>x>>y>>h; vec.push_back({x*x+y*y,h}); } sort(vec.begin(),vec.end(),cmp); int ans = 0,maxh = 0; for(int i=0;i<n;i++){ maxh = max(maxh,vec[i].second); ans = max(ans,maxh-vec[i].second); } cout<<ans<<endl; }
|