标签:while family mil cout weight php else long ++
#include<bits/stdc++.h>
typedef long long L;
using namespace std;
#define endl ‘\n‘
const int MAXN=5*1e4+5;
struct Point
{
int x,y,val;
}p[MAXN];
bool cmp(const Point &x,const Point &y)
{
if(x.x==0)return true;
if(y.x==0)return false;
return x.y/(double)x.x>=y.y/(double)y.x;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin>>T;
while(T--)
{
int n;
cin>>n;
for(int i=0;i<n;i++)cin>>p[i].x>>p[i].y>>p[i].val;
sort(p,p+n,cmp);
L sum1=0,sum2=0,ans=0;
for(int i=0;i<n;i++)
{
if(p[i].x<0||(p[i].x==0&&p[i].y<0))sum1+=p[i].val;
else sum2+=p[i].val;
}
for(int i=0;i<n;i++)
{
if(p[i].x<0||(p[i].x==0&&p[i].y<0))
{
sum1-=p[i].val;
sum2+=p[i].val;
}
else
{
sum1+=p[i].val;
sum2-=p[i].val;
}
ans=max(ans,sum1*sum2);
}
cout<<ans<<endl;
}
return 0;
}
标签:while family mil cout weight php else long ++
原文地址:http://www.cnblogs.com/zjnu/p/7367393.html