先考虑二维上的问题 然后就很好想到三维了
没有SPJ真蛋疼
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
inline char nc()
{
static char buf[100000],*p1=buf,*p2=buf;
if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
return *p1++;
}
inline void read(ll &x)
{
char c=nc(),b=1;
for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
struct Point{
ll x,y;
Point(ll x=0,ll y=0):x(x),y(y) {}
void read(){
::read(x); ::read(y);
}
bool operator < (const Point &B) const{
return x==B.x?y>B.y:x<B.x;
}
};
ll n;
pair<ll,Point> P[5005];
set<Point> Set;
typedef set<Point>::iterator ITER;
multiset<pair<ll,Point> > Ans;
ll ansx,ansy,ansz,ans=-1;
int main()
{
freopen("t.in","r",stdin);
freopen("t.out","w",stdout);
read(n);
for (int i=1;i<=n;i++)
P[i].second.read(),read(P[i].first);
P[++n]=make_pair(1000000,Point(0,0));
sort(P+1,P+n+1);
Set.insert(Point(0,1000000));
Set.insert(Point(1000000,0));
Ans.insert(make_pair((ll)1e12,Point(1000000,1000000)));
for (int i=1;i<=n;i++)
{
multiset<pair<ll,Point> >::iterator it=Ans.end(); it--;
if(P[i].first*it->first>ans)
ans=P[i].first*it->first,ansx=it->second.x,ansy=it->second.y,ansz=P[i].first;
Point pot=P[i].second;
if(Set.find(pot)!=Set.end()) continue;
Set.insert(pot);
ITER mt=Set.find(pot),lt,rt;
rt=lt=mt; lt--; rt++;
if(lt->y<pot.y) { Set.erase(mt); continue; }
Ans.erase(Ans.find(make_pair(rt->x*lt->y,Point(rt->x,lt->y))));
while (rt->y>pot.y)
{
ITER tem=rt; tem++;
Ans.erase(Ans.find(make_pair(tem->x*rt->y,Point(tem->x,rt->y))));
Set.erase(rt);
rt=mt; rt++;
}
Ans.insert(make_pair(mt->x*lt->y,Point(mt->x,lt->y)));
Ans.insert(make_pair(rt->x*mt->y,Point(rt->x,mt->y)));
}
if (ansx==1000000 && ansy==1000000 && ansz==1) swap(ansx,ansz);
printf("%lld %lld %lld\n",ansx,ansy,ansz);
return 0;
}