版权声明:欢迎转载!拒绝抄袭. https://blog.csdn.net/qq_36257146/article/details/87560255
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
struct Node
{
int x;
int y;
Node(int a,int b)
{
x = a;y = b;
}
bool operator < (const Node &a) const
{
if(a.y == y)
return a.x>x;
else
return a.y>y;
}
};
vector<Node>n1;
vector<Node>n2;
int main()
{
int c,n;
int x,y;
cin>>c;
while(c--)
{
n1.clear();
n2.clear();
int sum = 0;
cin>>n;
for(int i = 0;i<n;i++)
{
cin>>x>>y;
sum+=x;
n1.push_back(Node(n*x,y));
n2.push_back(Node(n*x,y));
}
sort(n1.begin(),n1.end());
for(int i = 0;i<n2.size();i++)
{
n2[i].x = 2*sum-n2[i].x;
}
sort(n2.begin(),n2.end());
int flag = 1;
for(int i = 0;i<n1.size();i++)
{
if(n1[i].x!=n2[i].x||n1[i].y!=n2[i].y)
{
flag = 0;
break;
}
}
if(!flag) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return 0;
}
/**
3
5
-2 5
0 0
6 5
4 0
2 3
4
2 3
0 4
4 0
0 0
4
5 14
6 10
5 10
6 14
**/